LED Blink


In this blog, we will see how to make LED to blink continuously using an Arduino nano development board. 

Components required:

  • Breadboard
  • Arduino nano
  • LED
  • Jumpers Wires
First, we have to make a program to upload in the Arduino nano board to make operation on the LED.


Here we have the LED blink program:

    void setup(){
    pinMode(2, OUTPUT);
    }
    void loop(){
    digitalWrite(2, HIGH);
    delay(1000);
    digitalWrite(2, LOW);
    delay(1000);
    }


According to the program we can see there are two parts of programs:


1. void setup(): The void setup() is the first function to be executed in the sketch and it is executed only once. It usually contains statements that set the pin modes on the Arduino to OUTPUT and INPUT, for example: pinMode (12, OUTPUT); pinMode(11, INPUT); Or to start the serial monitor example: serial.


2. void loop(): The void loop() is a function that executes indefinitely until you power off the Arduino.


So in the void setup() function, we have defined the Arduino PIN 2 as OUTPUT using the pinMode() function.

In the void loop() function there is an actual program that is going to make operations on the output LED. First, we have written digitalWrite(2, HIGH) which means that the PIN 2 is at a HIGH level(HIGH potential voltage level) which makes the LED glow. After this, we apply a delay of 1000 milliseconds which is equivalent to 1 second, the delay of 1 second will hold the LED to glow up-to 1 second. Then we have subsequent line digitalWrite(2, LOW) which means that the PIN is at the digital logic low level(LOW potential voltage level) due to low potential at Arduino nano PIN number 2 the LED will be turned off. And again we have applied the delay of 1 second to hold the LED in the off condition for 1 second. And after this, the whole void loop() program will be executed again and again until you power off the Arduino.


Functions that are used in the program:

1. digitalWrite(): The digitalWrite() function is used to Write a HIGH or a LOW value to a digital pin. If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.


2. delay(): The delay() function allows you to pause the execution of your Arduino program for a specified period. For that purpose, the method requires you to supply it with a whole number that specifies how many milliseconds the program should wait.


3. pinMode(): The pinMode() function is used to configure a specific pin to behave either as an input or an output. It is possible to enable the internal pull-up resistors with the mode INPUT_PULLUP.


Thank you for visiting.

Follow this blog using your Email.

Post a Comment (0)
Previous Post Next Post