LEDs in a parallel mode in IoT: Complete Code

Write a program in IoT to blink 5 LEDs in parallel mode with the delay of 1 second, 2 seconds, 3 seconds, 4 seconds, and 5 seconds.
setup()
Function
The setup()
function runs once when the Arduino is powered on or reset. It’s used to configure initial settings.
void setup()
{
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(2, OUTPUT);
}
pinMode(pin, mode)
sets the behavior of a pin: ,INPUTOUTPUT
, orINPUT_PULLUP
.pinMode(13, OUTPUT);
sets pin 13 as an output pin.- Similarly, pins 12, 8, 7, and 2 are also configured as outputs.
- These pins will later be used to control devices like LEDs or other digital output components.
loop()
Function
The loop()
function runs continuously after it setup () finishes. It controls the logic of the program.
void loop()
{
digitalWrite(13, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(13, LOW);
digitalWrite(13, HIGH);
turns ON the device (e.g., LED) connected to pin 13.delay(1000);
pauses the program for 1000 milliseconds (1 second).digitalWrite(13, LOW);
turns OFF pin 13.
digitalWrite(12, HIGH);
delay(2000); // Wait for 2000 millisecond(s)
digitalWrite(12, LOW);
Turns ON pin 12 for 2 seconds, then turns it OFF.
digitalWrite(8, HIGH);
delay(3000); // Wait for 3000 millisecond(s)
digitalWrite(8, LOW);
Turns ON pin 8 for 3 seconds, then turns it OFF.
digitalWrite(7, HIGH);
delay(4000); // Wait for 4000 millisecond(s)
digitalWrite(7, LOW);
Turns ON pin 7 for 4 seconds, then turns it OFF.
digitalWrite(2, HIGH);
delay(5000); // Wait for 5000 millisecond(s)
digitalWrite(2, LOW);
}
- Turns ON pin 2 for 5 seconds, then turns it OFF.
- After this, the loop starts again from the top.
CODE
// C++ code
//
void setup()
{
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(2, OUTPUT);
}
void loop()
{
digitalWrite(13, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
delay(2000); // Wait for 2000 millisecond(s)
digitalWrite(12, LOW);
digitalWrite(8, HIGH);
delay(3000); // Wait for 3000 millisecond(s)
digitalWrite(8, LOW);
digitalWrite(7, HIGH);
delay(4000); // Wait for 4000 millisecond(s)
digitalWrite(7, LOW);
digitalWrite(2, HIGH);
delay(5000); // Wait for 5000 millisecond(s)
digitalWrite(2, LOW);
}
OUTPUT
