Last active
July 2, 2017 12:39
-
-
Save lazytomatolab/28b72ecb57fc2dc9f8da41b711be0662 to your computer and use it in GitHub Desktop.
【Arduino SpeedUp】快速上手 Class 9 - 邏輯?旗標?按鈕特輯 2!更多資訊請造訪:http://www.lazytomatolab.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boolean state = false; | |
boolean buttonUp = true; | |
void setup() { | |
pinMode(13, OUTPUT); | |
digitalWrite(13, LOW); | |
pinMode(7, INPUT); | |
digitalWrite(7, HIGH); | |
} | |
void loop() { | |
if(digitalRead(7) != HIGH && buttonUp == true) { | |
state = !state; | |
digitalWrite(13, state); | |
buttonUp = false; | |
} | |
else if(digitalRead(7) == HIGH && buttonUp != true) { | |
buttonUp = true; | |
} | |
delay(10); // Delay 時間可視情況調整 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment