int Switch = 33; //setting Switch to pin 33
int LED_Red = 5; //setting Red LED to pin 5
int LED_Green = 18; //setting Green LED to pin 18
int LED_Blue = 19; //setting Blue LED to pin 19
int LED_Yellow = 21; //setting Yellow LED to pin 21
void setup() { //Setup for all pins used
pinMode (Switch, INPUT); //Defining Switch as an input
pinMode (LED_Red, OUTPUT); //Defining Red LED as an output
pinMode (LED_Green, OUTPUT); //Defining Green LED as an output
pinMode (LED_Blue, OUTPUT); //Defining Blue LED as an output
pinMode (LED_Yellow, OUTPUT); //Defining Yellow LED as an output
}
void loop() { //The loop that controls the flow of the program
if (digitalRead (Switch)==HIGH){ //Setting the switch equal to HIGH which means its ON
digitalWrite(LED_Red, HIGH); //Red LED turns on (steady state)
digitalWrite(LED_Green, HIGH); //Green LED turns on (steady state)
digitalWrite(LED_Blue, HIGH); //Blue LED turns on at this moment
digitalWrite(LED_Yellow, LOW); //Yellow LED is off at this moment
delay(1000); //The delay time of the 2 codes above where it will change to another state
digitalWrite(LED_Blue, LOW); //Blue LED at this time is off
digitalWrite(LED_Yellow, HIGH); //Yellow LED at this time is on
delay(1000); //The delay time of the 2 codes above where it will change to another state
}
else if (digitalRead (Switch)==LOW){ //Setting the switch equal to LOW which means its OFF
digitalWrite(LED_Blue, HIGH); //Blue LED turns on (steady state)
digitalWrite(LED_Yellow, HIGH); //Yellow LED turns on (steady state)
digitalWrite(LED_Red, HIGH); //Red LED turns on at this moment
digitalWrite(LED_Green, LOW); //Green LED is off at this moment
delay(1000); //The delay time of the 2 codes above where it will change to another state
digitalWrite(LED_Red, LOW); //Red LED at this time is off
digitalWrite(LED_Green, HIGH); //Green LED at this time is on
delay(1000); //The delay time of the 2 codes above where it will change to another state
}
}