How to blink an LED with Arduino nano


In previous tutorials we learnt about how to blink an LED under a specified amount of time in our code with an Arduino uno, also in this tutorial we will learn how to blink an LED with an Arduino nano. Steps in controlling an LED with an Arduino nano ain't different from that of Arduino uno. 

  
Materials.

  1. Arduino nano 
  2. 330 ohm resistor 
  3. LED 
  4. Wires
  5. Bread board 
  6. Battery







In the circuit diagram above an LED is connected with it positive terminal connected to the 330 ohm resistor in series to pin 13 while the negative terminal is connected to the ground pin(GND). 5v is supplied to the Arduino as shown in the circuit diagram.
After connecting the Arduino nano, the board is powered by a USB plugged into a computer for programming.

Plug in your board via the USB to your computer, open the Arduino IDE you've installed on your PC and open a new sketch. Copy the code below and upload to the board.


LED blinking with Arduino Code.

int led_pin=13; 
void setup() { pinMode(led_pin,OUTPUT); digitalWrite (led_pin,HIGH);   delay(1000);   digitalWrite(led_pin,LOW); }   
 void loop() { } Output:- Led will blink once... But modifying code, int led_pin=13; 
void setup () { pinMode(led_pin,OUTPUT); } 
void loop() { digitalWrite(led_pin,HIGH);  delay(500); digitalWrite(led_pin,LOW);  delay(500); } Output:- Led will blink for infinity


When the code is successfully uploaded the LED will start blinking based on time interval set in the Arduino code.
Now, we've successfully coded an Arduino nano to blink and LED on and off repeatedly, we can now move to more complex parts.
Techie Brainiac

The brain behind BuildNode and NodeHut, builder, Tech geek, entrepreneur, innovator, inventor and an embedded and electronics engineer. Got an industrial training at RLG institute of technology. I'm holding a degree in computer science and engineering and have written hundreds of articles and tutored a lot of beginners like you. .

Post a Comment

Previous Post Next Post