0% found this document useful (0 votes)
11 views3 pages

1

The document contains an Arduino code that controls three LEDs: red, yellow, and green, connected to pins 0, 1, and 2 respectively. In the setup function, all LEDs are configured as outputs. The loop function sequentially turns on each LED for specified durations while turning off the others.
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)
11 views3 pages

1

The document contains an Arduino code that controls three LEDs: red, yellow, and green, connected to pins 0, 1, and 2 respectively. In the setup function, all LEDs are configured as outputs. The loop function sequentially turns on each LED for specified durations while turning off the others.
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
You are on page 1/ 3

int led_red = 0; // the red LED is connected to Pin 0 of the Arduino

int led_yellow = 1; // the yellow LED is connected to Pin 1 of the Arduino

int led_green = 2; // the green LED is connected to Pin 2 of the Arduino

void setup() {

// set up all the LEDs as OUTPUT

pinMode(led_red, OUTPUT);

pinMode(led_yellow, OUTPUT);

pinMode(led_green, OUTPUT);

void loop() {

// turn the green LED on and the other LEDs off

digitalWrite(led_red, LOW);

digitalWrite(led_yellow, LOW);

digitalWrite(led_green, HIGH);

delay(2000); // wait 2 seconds

// turn the yellow LED on and the other LEDs off

digitalWrite(led_red, LOW);

digitalWrite(led_yellow, HIGH);

digitalWrite(led_green, LOW);

delay(1000); // wait 1 second

// turn the red LED on and the other LEDs off

digitalWrite(led_red, HIGH);

digitalWrite(led_yellow, LOW);

digitalWrite(led_green, LOW);

delay(3000); // wait 3 seconds

You might also like