Arduino Nano Basic LED Blinking

This beginner project blinks the Arduino Nano's built-in LED on pin 13 at 0.5 second intervals. The simple digitalWrite() and delay() functions demonstrate fundamental Arduino programming concepts.

No external components needed - uses the onboard LED already connected to pin 13 through a current-limiting resistor.

How It Works

Blinking an LED is the first program on any board because it exercises the complete toolchain — compiler, uploader, bootloader and hardware — with the smallest possible amount of code. If the LED blinks, everything underneath is working.

An LED is a diode: it conducts in one direction only and drops a roughly constant forward voltage regardless of current. A red LED drops about 1.8–2.2 V, blue and white closer to 3.0–3.4 V. Because the drop is fixed, the LED cannot limit its own current, and connecting it directly across a supply destroys it almost instantly.

A series resistor does the limiting. Its value follows from Ohm's law: R = (V_supply − V_forward) / I_desired. On this 5 V board driving a red LED at 10 mA, that is (5 − 2.0) / 0.01 ≈ 300 Ω, so the common 220 Ω or 330 Ω resistor is a sensible choice.

The classic sketch uses delay(), which blocks — nothing else can run while it waits. That is fine for a first program but becomes a problem the moment a project needs to do two things at once, which is why the version below also shows the millis() approach.

Components Needed

  • Arduino Nano board
  • LED Blinking module
  • Breadboard and jumper wires
  • USB cable for programming and power
  • Arduino IDE 2.x with the correct board package installed

Wiring to the Arduino Nano

Put the resistor in series with the LED between D2 and GND. The long leg is the anode and goes towards the pin; the short leg, also marked by a flat on the plastic rim, is the cathode and goes to ground. Reversed, the LED simply does not light — it is not damaged by a few volts of reverse bias at this scale.

The resistor can sit on either side of the LED; current is the same throughout a series circuit. Putting it on the anode side is conventional only because it reads more naturally.

The 5 V rail leaves comfortable headroom for any LED colour. Most boards also have a built-in LED on LED_BUILTIN, which needs no external parts at all.

ConnectionArduino Nano pinFunction
LED anode (long leg)D2 via resistorDriven output
LED cathode (short leg)GNDReturn path
220–330 Ω resistorIn series with the LEDLimits current — required

Build and Upload

1. Install Arduino IDE: Download from arduino.cc

2. Connect Nano: Plug into USB port

3. Select Board: Tools → Board → Arduino Nano

4. Select Processor: Tools → Processor → ATmega328P

5. Upload: Click Upload button (→)

6. Open Serial Monitor: Tools → Serial Monitor (9600 baud)

Multiple LEDs on pins 8,9,10

Pushbutton control

Potentiometer brightness (PWM)

Serial commands from computer

Example Code

Blinking with delay() and the non-blocking millis() pattern side by side. Upload it with the board set to Arduino Nano and open the Serial Monitor at 9600 baud.

Blinking with delay() and the non-blocking millis() pattern side by side
const int LED_PIN  = 2;
const int LED_2    = LED_BUILTIN;
const unsigned long INTERVAL_MS = 500;

unsigned long lastToggle = 0;
bool ledState = false;

void setup() {
  Serial.begin(9600);
  pinMode(LED_PIN, OUTPUT);
  pinMode(LED_2, OUTPUT);
}

void loop() {
  // Non-blocking: the loop keeps running, so other work can happen here
  if (millis() - lastToggle >= INTERVAL_MS) {
    lastToggle = millis();
    ledState = !ledState;
    digitalWrite(LED_PIN, ledState ? HIGH : LOW);
    Serial.println(ledState ? "on" : "off");
  }

  // The blocking equivalent, shown for comparison — nothing else can run:
  // digitalWrite(LED_PIN, HIGH); delay(500);
  // digitalWrite(LED_PIN, LOW);  delay(500);
}

Applications

A led blinking turns up in a wide range of projects. These are the uses where it is the right choice rather than a compromise:

  • Verifying a new board, toolchain and USB connection work
  • Status and heartbeat indicators showing firmware is alive
  • Error signalling through distinct blink patterns
  • Teaching digital output, timing and the cost of blocking code
  • Visual debugging where no serial connection is available

Working with the Arduino Nano

The Arduino Nano is built around the ATmega328P and runs on 5 V logic with 2 KB of SRAM and 32 KB of program flash. These details change how this circuit is wired and what the sketch can do, so they are worth stating plainly before you build.

The Nano shares the Uno’s ATmega328P but adds A6 and A7, which are analog-input only and cannot be used as digital pins.

Its DIP footprint drops straight into a breadboard, which suits permanent sensor builds.

Older clones use the CH340 USB bridge and may need that driver plus the "ATmega328P (Old Bootloader)" processor option.

Arduino Nano characteristicValueWhy it matters here
Logic voltage5 VMatches most hobby modules directly
ADC resolution10-bit (0–1023)Sets how finely an analog reading can be resolved
Analog inputsA0–A7 (eight channels, two more than the Uno)Determines how many analog sensors can share the board
PWM outputsD3, D5, D6, D9, D10 and D11Needed for brightness, speed and tone control
I²C pinsA4 (SDA) and A5 (SCL)Fixed by hardware — wiring copied from another board may not match
Interrupt pinsD2 and D3 onlyRequired for counting fast or asynchronous events
Seriala single hardware UART shared with USBMonitor runs at 9600 baud by default

Troubleshooting

Most problems with this module fall into a handful of categories. Work through these before suspecting the part itself:

  • The LED never lights — it is reversed. Long leg to the resistor and pin, short leg to ground.
  • It lit once brightly then died — the series resistor is missing.
  • It is very dim — the resistor is too large, or a blue/white LED is being driven from 3.3 V.
  • Nothing uploads — the wrong board or port is selected, or a driver is missing for a clone board.
  • It blinks at the wrong rate — check whether the sketch is using delay() twice per cycle; total period is the sum of both.
  • Code written for an ESP board gives odd analog values — the Arduino Nano uses a 10-bit ADC returning 0–1023; rescale any constant taken from a 12-bit example.
  • An I²C sensor is not found after copying wiring from another Arduino — on the Arduino Nano I²C is on A4 (SDA) and A5 (SCL).

Taking It Further on the Arduino Nano

Once the basic reading works, where you go next depends very much on which board you are using. These are the directions that suit the Arduino Nano specifically:

The Nano’s DIP footprint makes it the natural choice once a breadboard prototype becomes a soldered build. Mount it on female headers rather than soldering it down, so the board can be recovered if the project is retired.

With A6 and A7 available in addition to A0–A5, the Nano can read two more analog sensors than an Uno. Remember that those two pins are analog-input only — they cannot be used with digitalWrite or as digital inputs.

For battery-powered builds, the Nano’s regulator and USB bridge dominate idle current. Powering the 5V pin directly from a regulated supply and removing the power LED substantially extends runtime.

Notes and Practical Limits

A GPIO can source only limited current — around 20 mA on the ATmega328P, with a lower total across all pins. Driving several LEDs at full brightness from pins exceeds that; use a transistor or a dedicated driver.

The millis() pattern is worth learning immediately rather than later. Almost every real project needs to blink something while reading a sensor, and delay() makes that impossible without restructuring.