Arduino Nano: Simple LED Blink Program

To get started with Arduino Nano, the first code you’ll often write is the “Blink” example. This program makes the built-in LED and External LED blink ON and OFF. The Arduino Nano, like other Arduino boards, has a built-in LED connected to pin 13.

If you want to use an external LED:

If you want to use an external LED instead of the built-in one, you’ll need a few components:

Components Required:

  • 1 x LED
  • 1 x 220Ω Resistor
  • Jumper wire
  • Breadboard

Wiring Steps:

  1. LED Connections:
    • Connect the long leg (anode) of the LED to digital pin 13 on the Arduino Nano.
    • Connect the short leg (cathode) of the LED to one end of the 220Ω resistor.
    • Connect the other end of the 220Ω resistor to GND (ground) on the Arduino Nano.

Here’s a simple Arduino code to blink the LED:

// Define the pin where the LED is connected
const int ledPin = 13;  // Pin 13 is usually connected to an onboard LED on many Arduino boards

void setup() {
  // Initialize the LED pin as an output
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // Turn the LED on (HIGH is the voltage level)
  digitalWrite(ledPin, HIGH);
  
  // Wait for 1000 milliseconds (1 second)
  delay(1000);
  
  // Turn the LED off (LOW is the voltage level)
  digitalWrite(ledPin, LOW);
  
  // Wait for another 1000 milliseconds (1 second)
  delay(1000);
}

Notes:

  • The resistor is used to limit the current flowing through the LED, preventing damage.
  • You can adjust the resistor value (e.g., 330Ω or 470Ω) depending on the type of LED you are using.

Once you make these connections, upload the code to your Arduino Nano, and the external LED should blink just like the built-in one.