/*Master Traffic Signal*/
// Define pin numbers for the red, yellow, and green LEDs
int red = 11; // Pin connected to the red LED
int yellow = 10; // Pin connected to the yellow LED
int green = 9; // Pin connected to the green LED
void setup()
{
// Set the LED pins as outputs so they can be turned on/off
pinMode(red, OUTPUT);
pinMode(yellow, OUTPUT);
pinMode(green, OUTPUT);
}
void loop()
{
// Turn on the red LED for 5 seconds to simulate a red light
digitalWrite(red, HIGH);
delay(5000); // Wait for 5000 milliseconds (5 seconds)
digitalWrite(red, LOW); // Turn off the red LED
// Turn on the yellow LED for 1 second to simulate a yellow light
digitalWrite(yellow, HIGH);
delay(1000); // Wait for 1000 milliseconds (1 second)
digitalWrite(yellow, LOW); // Turn off the yellow LED
delay(500); // Small delay before repeating the yellow signal
// Flash the yellow LED for another second to emphasize the transition
digitalWrite(yellow, HIGH);
delay(1000); // Wait for 1 second
digitalWrite(yellow, LOW); // Turn off the yellow LED
delay(500); // Short delay before switching to green light
// Turn on the green LED for 5 seconds to simulate a green light
digitalWrite(green, HIGH);
delay(5000); // Wait for 5 seconds
digitalWrite(green, LOW); // Turn off the green LED
// Flash the yellow LED again to indicate the transition back to red
digitalWrite(yellow, HIGH);
delay(1000); // Flash for 1 second
digitalWrite(yellow, LOW); // Turn off the yellow LED
delay(500); // Short delay
// Flash the yellow LED again
digitalWrite(yellow, HIGH);
delay(1000); // Flash for 1 second
digitalWrite(yellow, LOW); // Turn off the yellow LED
delay(500); // Short delay before repeating the cycle
}