Blink 3 LEDs Alternatively in IoT: A Complete Code

Blink 3 LEDs Alternatively in IoT

Write a program to interface LEDs on pin nos. 10, 11, 12, and 13 and blink them alternately at a delay of 1 second.

Blink 3 LEDs Alternatively in IoT the in and LED pins are 10, 11, 12, and 13, and the delay is 1 second.

Void setup()

This function runs once when the Arduino is powered on or reset. It is used to configure settings like pin modes.

pinMode(10, OUTPUT);

This line sets pin 10 as an output pin. It means the pin will send out voltage (used to control an LED).

pinMode(11, OUTPUT);

Sets pin 11 as an output pin.

pinMode(12, OUTPUT);

Sets pin 12 as an output pin.

pinMode(13, OUTPUT);

Sets pin 13 as an output pin.

All these pinMode calls prepare the four pins to control LEDs.

void loop()

This function runs repeatedly after—it setup()contains the main logic.

digitalWrite(10, HIGH);

Turns ON the LED connected to pin 10 by sending 5V (HIGH) to it.

Important HTML Programs for Exam

delay(1000);

Waits for 1 second (1000 milliseconds).

digitalWrite(10, LOW);

Turns OFF the LED on pin 10.

digitalWrite(11, HIGH);

Turns ON the LED connected to pin 11.

delay(1000);

Waits for 1 second.

digitalWrite(11, LOW);

Turns OFF the LED on pin 11.

digitalWrite(12, HIGH);

Turns ON the LED connected to pin 12.

delay(1000);

Waits for 1 second.

digitalWrite(12, LOW);

Turns OFF the LED on pin 12.

digitalWrite(13, HIGH);

Turns ON the LED connected to pin 13.

delay(1000);

Waits for 1 second.

digitalWrite(13, LOW);

Turns OFF the LED on pin 13.

Then the loop starts over, and this blinking pattern continues forever.

CODE

//LED blink alternatively
void setup()
{
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
}
void loop()
{
digitalWrite(10,HIGH);
delay(1000);
digitalWrite(10,LOW);
digitalWrite(11,HIGH);
delay(1000);
digitalWrite(11,LOW);
digitalWrite(12,HIGH);
delay(1000);
digitalWrite(12,LOW);
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
}

OUTPUT

Blink 3 LEDs Alternatively in IoT
Share your love
Er. Anshima
Er. Anshima
Articles: 16

Leave a Reply

Your email address will not be published. Required fields are marked *