// === CompartR ====
// Module #4 project
// Define some labels
const int Red_LED_East_West = 14; // The EAST WEST RED LED is wired to ESP32 board pin GPIO14
const int Yellow_LED_East_West =12; // The EAST WEST YELLOW LED is wired to ESP32 board pin GPIO12
const int Green_LED_East_West = 13; // The EAST WEST GREEN LED is wired to ESP32 board pin GPIO13
const int Red_LED_North_South = 25; // The NORTH SOUTH RED LED is wired to Mega board pin GPIO25
const int Yellow_LED_North_South = 26; // The yellow LED_North_South is wired to Mega board pin GPIO 26
const int Green_LED_North_South = 27; // The NORTH SOUTH GREEN LED is wired to Mega board pin GPIO 27
// the setup function runs once when you press reset or power the board
void setup() {
pinMode(Red_LED_East_West, OUTPUT); // initialize digital pin GPIO14 (EAST WEST RED LED) as an output.
pinMode(Yellow_LED_East_West, OUTPUT); // initialize digital pin GPIO12 (EAST WEST YELLOW LED) as an output.
pinMode(Green_LED_East_West, OUTPUT); // initialize digital pin GPIO13 (EAST WEST GREEN LED) as an output.
pinMode(Red_LED_North_South, OUTPUT); // initialize digital pin GPIO25(NORTH SOUTH RED LED) as an output.
pinMode(Yellow_LED_North_South, OUTPUT); // initialize digital pin GPIO26 (yellow LED_North_South) as an output.
pinMode(Green_LED_North_South, OUTPUT); // initialize digital pin GPIO27 (NORTH SOUTH GREEN LED) as an output.
}
// the loop function runs over and over again forever
void loop() {
// The next three lines of code turn on the EAST WEST RED LED
digitalWrite(Red_LED_East_West, HIGH); // This should turn on the EAST WEST RED LED
digitalWrite(Yellow_LED_East_West , LOW); // This should turn off the EAST WEST YELLOW LED
digitalWrite(Green_LED_East_West, LOW); // This should turn off the EAST WEST GREEN LED
delay(1000); //Extended time for Red light#1 before the Green of the other side turns ON
// The next three lines of code turn on the NORTH SOUTH GREEN LED for 2 seconds
digitalWrite(Red_LED_North_South, LOW); // This should turn off the NORTH SOUTH RED LED
digitalWrite(Yellow_LED_North_South , LOW); // This should turn off the yellow LED_North_South
digitalWrite(Green_LED_North_South, HIGH); // This should turn on the NORTH SOUTH GREEN LED
delay(2000); // wait for 2 seconds
// The next three lines of code turn on the EAST WEST RED LED
digitalWrite(Red_LED_East_West, HIGH); // This should turn on the EAST WEST RED LED
digitalWrite(Yellow_LED_East_West , LOW); // This should turn off the EAST WEST YELLOW LED
digitalWrite(Green_LED_East_West, LOW); // This should turn off the EAST WEST GREEN LED
// The next three lines of code turn on the EAST WEST YELLOW LED
digitalWrite(Red_LED_North_South, LOW); // This should turn off the NORTH SOUTH RED LED
digitalWrite(Yellow_LED_North_South , HIGH); // This should turn on the NORTH SOUTH YELLOW LED
digitalWrite(Green_LED_North_South, LOW); // This should turn off the NORTH SOUTH GREEN LED
delay(2000); // wait for 2 seconds
// The next three lines of code turn on the NORTH SOUTH RED LED
digitalWrite(Red_LED_North_South, HIGH); // This should turn on the NORTH SOUTH RED LED
digitalWrite(Yellow_LED_North_South , LOW); // This should turn off the NORTH SOUTH YELLOW LED
digitalWrite(Green_LED_North_South, LOW); // This should turn off the NORTH SOUTH GREEN LED
delay(1000); //Extended time for Red light#2 before the Green of the other side turns ON
// The next three lines of code turn on the EAST WEST GREEN LED
digitalWrite(Red_LED_East_West, LOW); // This should turn off the EAST WEST RED LED
digitalWrite(Yellow_LED_East_West , LOW); // This should turn off the EAST WEST YELLOW LED
digitalWrite(Green_LED_East_West, HIGH); // This should turn on the EAST WEST GREEN LED
delay(2000); // wait for 1 second
// The next three lines of code turn on the EAST WEST YELLOW LED
digitalWrite(Red_LED_East_West, LOW); // This should turn off the EAST WEST RED LED
digitalWrite(Yellow_LED_East_West , HIGH); // This should turn on the EAST WEST YELLOW LED
digitalWrite(Green_LED_East_West, LOW); // This should turn off the EAST WEST GREEN LED
// The next three lines of code turn on the NORTH SOUTH RED LED
digitalWrite(Red_LED_North_South, HIGH); // This should turn on the NORTH SOUTH RED LED
digitalWrite(Yellow_LED_North_South , LOW); // This should turn off the NORTH SOUTH YELLOW LED
digitalWrite(Green_LED_North_South, LOW); // This should turn off the NORTH SOUTH GREEN LED
delay(2000); // wait for 1 second
}