Switching It Up

When the switch is turned on, the blue light is illuminated and the red and green lights are off. When the switch is turned off, the red and green lights are on and the blue light is off.

IMG_4591

IMG_4594

IMG_4595


CODE:

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

}//Setup

void loop(){

if (digitalRead(4) == HIGH){
digitalWrite(10,HIGH);
digitalWrite(8,LOW);
digitalWrite(7,HIGH);

}//if HIGH

if(digitalRead(4) == LOW) {
digitalWrite(10,LOW);
digitalWrite(8,HIGH);
digitalWrite(7,LOW);

}//if LOW

Leave a Reply