Instantly share code, notes, and snippets.

Embed
What would you like to do?
【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