Glow an LED using Arduino Code Explanation Line by Line

Glow an LED using Arduino


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

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

Leave a Comment

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

©Postnetwork-All rights reserved.