ad space

LED blink Arduino Nano Tutorial

Here we will show how to turn on and off a LED with Arduino Nano. Such led blink is also known as hello world project for microcontrollers or microcontroller board like Arduino Nano. Arduino Nano is same as Arduino Uno which uses the same micrcontroller ATmega328p. The difference is the small size of Arduino Nano(hence called Nano) which can be useful in projects where size of the electronics system matters.

Arduino Nano LED blink on breadboard

The following are the materials required for this tutorial:

- Arduino Nano
- LED
- 220Ohm resistor
- Connecting Wires
- Breadboard
- USB cable
- Arduino IDE

The LED is connected to digital pin 9 with a 220Ohm resistor as shown in the following circuit schematic.

Arduino Nano LED blink circuit schematic

Arduino Nano LED Blink Program Code

The Arduino Nano program code for led blinking is below.


const int ledPin = 9;
void setup() {
// put your setup code here, to run once:
pinMode(ledPin, OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}

In the program code first we have set alias name "ledPin" for the pin 9 where the LED is connected. This alias name ledPin for pin 9 can be useful because first, it is easier to remember what is being done with this pin if the program were large and second if we need to connect the LED to different pin then we can just change the pin number at the top. For large program this becomes efficient way of coding.

In the setup() function we have set the led pin to output. In the loop() function we send high pulse, then set a delay of 1 second or 1000 milli seconds and then send low pulse also for period of 1000ms or 1 second. This then will blink the LED.

Video Demonstration of LED Control using Arduino Nano

The following video demonstrate how to blink the LED using Arduino Nano.

In the next Arduino push button led tutorial we show how to turn on or off a LED using a push button.

1 Comments

Previous Post Next Post