Skip to content

Instantly share code, notes, and snippets.

@mikbuch
Last active March 22, 2019 21:33
Show Gist options
  • Save mikbuch/9e38d94369180c6972e17a7a333f9208 to your computer and use it in GitHub Desktop.
Save mikbuch/9e38d94369180c6972e17a7a333f9208 to your computer and use it in GitHub Desktop.
int button1 = 11;
int button2 = 12;
int led1 = 7;
int led2 = 6;
void setup() {
Serial.begin(9600);
pinMode(button1, INPUT);
pinMode(led1, OUTPUT);
pinMode(button2, INPUT);
pinMode(led2, OUTPUT);
}
void loop() {
if (digitalRead(button1) == LOW or digitalRead(button2) == LOW){
//IF BUTTON 1 IS HIGH IT MEANS THAT IT IS PUSHED DOWN
if (digitalRead(button1) == LOW){
digitalWrite(led1, HIGH);
digitalWrite(led2, LOW);
//WAIT 5 SEC
delay(5000);
digitalWrite(led1, LOW);
}
if (digitalRead(button2) == LOW){
digitalWrite(led2, HIGH);
digitalWrite(led1, LOW);
delay(5000);
digitalWrite(led2, LOW);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment