Double the switches, double the fun

Video

Meet the two switches involved in making this project:

Caleb's first soldered piece, ever
Mr. panic button from last week
Emily's Switch
the well-soldered not-so-panic button

 

…and the full setup:

a tad complicado

 

Using the code below, we made a setup which set off different LED light combinations based on which switches were open and closed. Watch the video to view all of the different LED blinking combinations.

void setup(){
pinMode(7,OUTPUT);
pinMode(10, OUTPUT);
pinMode(8,INPUT);
pinMode(9,INPUT);
}

void loop(){

if (digitalRead(8) == HIGH){
digitalWrite(7,HIGH);
delay(300);
digitalWrite(7,LOW);
delay(300);
}

if (digitalRead(9) == HIGH){
digitalWrite(10,HIGH);
delay(100);
digitalWrite(10,LOW);
delay(100);

}
}

Leave a Reply