/*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
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C
r1:1
r1:2
r2:1
r2:2
r3:1
r3:2