/*#define G1 2
#define Y1 4
#define R1 5
#define G2 19
#define Y2 18
#define R2 21
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(G1, OUTPUT);//Green1
pinMode(Y1, OUTPUT);//Yellow1
pinMode(R1, OUTPUT);//Red1
pinMode(Y2, OUTPUT);//Yellow2
pinMode(G2, OUTPUT);//Green2
pinMode(R2, OUTPUT);//Red2
}
*/
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(2, OUTPUT);//Green1
pinMode(4, OUTPUT);//Yellow1
pinMode(5, OUTPUT);//Red1
pinMode(18, OUTPUT);//Yellow2
pinMode(19, OUTPUT);//Green2
pinMode(21, OUTPUT);//Red2
}
// the loop function runs over and over again forever
void loop() {
/*Case:1 (Red1 & Green2) are on)*/
digitalWrite(2, LOW); // turn the LED on (HIGH is the voltage level) yellow1
digitalWrite(4, LOW); // turn the LED on (HIGH is the voltage level) Green1
digitalWrite(5, HIGH); // turn the LED off by making the voltage LOW Red1
digitalWrite(18, LOW); // turn the LED off by making the voltage LOW yellow2
digitalWrite(19, HIGH); // turn the LED off by making the voltage LOW Green2
digitalWrite(21, LOW); // turn the LED on (HIGH is the voltage level) Red2
delay(5000);// Pin 17 Other Traffic
/*Case:2 (Red1 & Yellow2) are on)*/
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW Yellow1
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW Green1
digitalWrite(5, HIGH); // turn the LED on (HIGH is the voltage level) Red1
digitalWrite(18, HIGH); // turn the LED off by making the voltage LOW Yellow2
digitalWrite(19, LOW); // turn the LED off by making the voltage LOW Green2
digitalWrite(21, LOW); // turn the LED on (HIGH is the voltage level) Red2
delay(2000);// Pin 16 Other Traffic
/*Case:3 (Green2 & Red2) are on)*/
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW Yellow1
digitalWrite(4, HIGH); // turn the LED off by making the voltage LOW Green1
digitalWrite(5, LOW); // turn the LED off by making the voltage LOW Red1
digitalWrite(18, LOW); // turn the LED off by making the voltage LOW Yellow2
digitalWrite(19, LOW); // turn the LED off by making the voltage LOW Green2
digitalWrite(21, HIGH); // turn the LED on (HIGH is the voltage level) Red2
delay(5000);// Pin 5 Other Traffic
/*Case:4 (Yellow1 & Red2) are on)*/
digitalWrite(2, HIGH); // turn the LED off by making the voltage LOW Yellow1
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW Green1
digitalWrite(5, LOW); // turn the LED off by making the voltage LOW Red1
digitalWrite(18, LOW); // turn the LED off by making the voltage LOW Yellow2
digitalWrite(19, LOW); // turn the LED off by making the voltage LOW Green2
digitalWrite(21, HIGH); // turn the LED on (HIGH is the voltage level) Red2
delay(2000);// Pin 5 Other Traffic
}