Skip to content

Instantly share code, notes, and snippets.

@lazytomatolab
Last active July 2, 2017 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazytomatolab/28b72ecb57fc2dc9f8da41b711be0662 to your computer and use it in GitHub Desktop.
Save lazytomatolab/28b72ecb57fc2dc9f8da41b711be0662 to your computer and use it in GitHub Desktop.
【Arduino SpeedUp】快速上手 Class 9 - 邏輯?旗標?按鈕特輯 2!更多資訊請造訪:http://www.lazytomatolab.com
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