Glow Two-LED Alternatively Using Arduino

Arduino Code-


void setup()
{
pinMode(8, OUTPUT);
pinMode(10, OUTPUT);
}
void loop()
{
digitalWrite(8, HIGH);
digitalWrite(10, LOW);
delay(2000);
digitalWrite(8, LOW);
digitalWrite(10, HIGH);
delay(2000);
}

Program

Description-


setup() function is used to configure Pins for INPUT, OUTPUT, signal rate etc.
Block of setup() function starts here.
It indicates pin no. 8 is used for OUTPUT.
It indicates pin no. 10 is used for OUTPUT.
Block of setup() function ends here.
Statements inside loop() function run forever.
Block of loop() function starts here.
digitalWrite(8, HIGH) statement will make pin no. 8 supply voltage HIGH.
digitalWrite(10, LOW) statement will make pin no. 10 supply voltage LOW.
delay(2000) will make LED glow for 2000 milliseconds.
digitalWrite(8, LOW) statement will make pin no. 8 supply voltage LOW.
digitalWrite(10, HIGH) statement will make pin no. 10 supply voltage HIGH.
delay(2000) will make LED off for 2000 milliseconds.
End of loop() function.

See video:-

 

 

Leave a Comment

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

©Postnetwork-All rights reserved.