int SWITCH = 13; //set 13 pin as switch//
int RED = 21; //set 21 pin as RED LED//
int GREEN = 19; //set 19 pin as RED LED//
int BLUE = 18; //set 18 pin as RED LED//
int YELLOW = 5; //set 5 pin as RED LED//
void setup() { //set up for the inputs and outputs//
pinMode(SWITCH, INPUT); //set switch as input//
pinMode(RED, OUTPUT); //set Red LED as output//
pinMode(GREEN, OUTPUT); //set Green LED as output//
pinMode(BLUE, OUTPUT); //set Blue LED as output//
pinMode(YELLOW, OUTPUT); //set Yellow LED as output//
}
void loop() { //loops the code//
if(digitalRead(SWITCH)==HIGH){ //switch is turned on//
digitalWrite(RED, HIGH); //turn on the Red LED//
digitalWrite(GREEN, HIGH); //turn on the Green LED//
digitalWrite(BLUE, HIGH); //turn on the Blue LED//
digitalWrite(YELLOW, LOW); //turn off the Red LED//
delay(500); //delay for the Blue and Yellow LED//
digitalWrite(BLUE, LOW); //turn off the Blue LED//
digitalWrite(YELLOW, HIGH); //turn on the Yellow LED//
delay(500); //delay for the Blue and Yellow LED//
}
if(digitalRead(SWITCH)==LOW){ //switch is turned off//
digitalWrite(BLUE, HIGH); //turn on the Blue LED//
digitalWrite(YELLOW, HIGH); //turn on the Yellow LED//
digitalWrite(RED, HIGH); //turn on the Red LED//
digitalWrite(GREEN, LOW); //turn off the Green LED//
delay(500); //delay for the Red and Green LED//
digitalWrite(RED, LOW); //turn off the Red LED//
digitalWrite(GREEN, HIGH); //turn on the Green LED//
delay(500); //delay for the Red and Green LED//
}
}