0% found this document useful (0 votes)
10 views1 page

Traffic Signals

Uploaded by

Zohaib Javed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

Traffic Signals

Uploaded by

Zohaib Javed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

// Define pin numbers for the LEDs

#define RED 10

#define YELLOW 9

#define GREEN 8

void setup() {

// Set the pins as output

pinMode(RED, OUTPUT);

pinMode(YELLOW, OUTPUT);

pinMode(GREEN, OUTPUT);

void loop() {

// Turn on the green LED (Go)

digitalWrite(GREEN, HIGH);

delay(5000); // Wait for 5 seconds

digitalWrite(GREEN, LOW);

// Turn on the yellow LED (Prepare)

digitalWrite(YELLOW, HIGH);

delay(2000); // Wait for 2 seconds

digitalWrite(YELLOW, LOW);

// Turn on the red LED (Stop)

digitalWrite(RED, HIGH);

delay(5000); // Wait for 5 seconds

digitalWrite(RED, LOW);

You might also like