Skip to content

Instantly share code, notes, and snippets.

@lazytomatolab
Created August 20, 2017 13:51
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/00832566cc162a0808ba93345a81c19c to your computer and use it in GitHub Desktop.
Save lazytomatolab/00832566cc162a0808ba93345a81c19c to your computer and use it in GitHub Desktop.
【Arduino SpeedUp】快速上手 Class 10 - 互動?遊戲?按鈕特輯 3!更多資訊請造訪:http://www.lazytomatolab.com
boolean state = false;
boolean buttonUp = true;
void setup() {
pinMode(7, INPUT);
pinMode(8, OUTPUT); // INA
digitalWrite(8, LOW);
pinMode(9, OUTPUT); // INB
digitalWrite(9, LOW);
}
void loop() {
if(digitalRead(7) != HIGH && buttonUp == true) {
state = !state;
digitalWrite(8, state);
buttonUp = false;
}
else if(digitalRead(7) == HIGH && buttonUp != true) {
buttonUp = true;
}
delay(100);
}
boolean state = false;
boolean buttonUp = true;
void setup() {
pinMode(7, INPUT);
pinMode(8, OUTPUT); // INA
digitalWrite(8, !state);
pinMode(9, OUTPUT); // INB
digitalWrite(9, state);
}
void loop() {
if(digitalRead(7) != HIGH && buttonUp == true) {
digitalWrite(8, state);
state = !state;
digitalWrite(9, state);
buttonUp = false;
}
else if(digitalRead(7) == HIGH && buttonUp != true) {
buttonUp = true;
}
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment