Lesson 1

Blinking an LED with Arduino UNO

Learn how to connect an LED to an Arduino UNO and write a simple program to make it blink automatically.

  • Published:
  • 9 Views
  • Difficulty: Beginner
  • Reading time: 8 min

Overview

Introduction

In this lesson, you will learn how to blink a Light Emitting Diode (LED) using an Arduino UNO. An LED is a small electronic component that produces light when electric current flows through it in the correct direction.

Blinking an LED is one of the first practical projects beginners complete when learning Arduino programming. It introduces the basic concepts of digital outputs, electronic circuit connections, and writing programs to control external components.

By the end of this lesson, you will have built a simple circuit that automatically turns an LED ON for one second and OFF for one second, repeating continuously.

What You Will Learn

  • How an LED works and how to identify its terminals.
  • How to connect an LED to an Arduino UNO.
  • Why a current-limiting resistor is important.
  • How to configure an Arduino digital pin as an output.
  • How to write and upload a simple Arduino program.
  • How to use pinMode(), digitalWrite(), and delay().
  • How to change the blinking speed of an LED.

Real-World Applications

LED blinking circuits are commonly used in electronic systems for:

  • Power and status indicators.
  • Warning and alarm systems.
  • Traffic light control projects.
  • Robotics and automation systems.
  • Electronic troubleshooting and testing.
  • Visual notifications in embedded systems.

An embedded system is an electronic system that uses a microcontroller or processor to perform a specific task.

Requirements

The following components are required for this project:

Component Quantity Price Availability Action
Arduino UNO R3 1 ₵149.00 383 in stock Add to Cart
5mm LED (Red) Red colour 1 ₵5.00 800 in stock Add to Cart
220Ω Resistor (¼W) 1 ₵3.00 137 in stock Add to Cart
Breadboard (400 points) 1 ₵15.00 534 in stock Add to Cart
Jumper wires (male–male) 5 Not sold here —

Only components that are available in our store are included in the total.

Items already in your cart are topped up to the required quantity, not duplicated.

Component Information

Arduino UNO R3

The Arduino UNO R3 is a microcontroller development board based on the ATmega328P microcontroller.

A microcontroller is a small programmable electronic chip that controls other electronic components.

The Arduino UNO R3 operates at a logic voltage of 5 V and provides digital input/output pins that can be programmed to control external devices.

5mm Red LED

A red LED produces visible red light when current flows through it in the forward direction.

A typical red LED has a forward voltage of approximately 1.8 V to 2.2 V, depending on its specifications.

220Ω Resistor

The resistor limits the electrical current flowing through the LED.

This helps protect both the LED and the Arduino output pin from excessive current.

Breadboard

A breadboard allows electronic components to be connected without soldering.

It is useful for experimenting with electronic circuits before building permanent projects.

Safety Precautions

  • Disconnect the Arduino USB cable before making or changing circuit connections.
  • Never connect an LED directly to an Arduino output without a suitable current-limiting resistor.
  • Check the positive and negative terminals of the LED before applying power.
  • Avoid connecting an Arduino output pin directly to GND while the pin is configured HIGH.
  • Use the Arduino’s USB connection for this project. No external power supply is necessary.
  • Do not connect this circuit to household 230 V AC mains electricity.

Principle of Operation

3.1 What Is an LED?

LED stands for Light Emitting Diode.

It is a semiconductor component that converts electrical energy into light when current flows through it in the forward direction.

An LED has two terminals

Anode (+): The positive terminal.

Cathode (−): The negative terminal.

On a standard new through-hole LED, the longer leg is usually the anode, while the shorter leg is usually the cathode.

The flat edge on the LED body commonly indicates the cathode.

For the LED to illuminate, its anode must be at a higher electrical potential than its cathode, and current must be limited to a safe level.

3.2 Understanding Digital Output

The Arduino UNO has digital input/output pins.

These pins can read digital signals or generate digital output signals.

A digital signal normally has two states:

HIGH: The Arduino drives the output towards 5 V.

LOW: The Arduino drives the output towards 0 V.

In this project, we will use digital pin 8 to control the LED.

When pin 8 is HIGH, electrical current flows through the resistor and LED to GND.

The LED turns ON.

When pin 8 is LOW, the voltage across the LED circuit becomes approximately zero.

The LED turns OFF.

3.3 Why Do We Need a Resistor?

An LED does not limit its own current sufficiently when connected directly to a voltage source.

Without a suitable resistor or current-limiting circuit, excessive current may damage the LED or the Arduino output pin.

The current flowing through the LED can be estimated using Ohm’s law.

Ohm’s Law:

V = I × R

Where:

V = Voltage in volts (V)

I = Current in amperes (A)

R = Resistance in ohms (Ω)

For an LED connected in series with a resistor:

I = (Vs − Vf) ÷ R

Where:

Vs = Supply voltage

Vf = LED forward voltage

R = Series resistor value

Assume:

Arduino output voltage = 5 V

Red LED forward voltage = 2 V

Resistor value = 220 Ω

Therefore:

I = (5 V − 2 V) ÷ 220 Ω

I = 3 V ÷ 220 Ω

I ≈ 0.0136 A = 13.6 mA

This is an approximate current. The actual current depends on the LED and Arduino output characteristics.

A 220Ω resistor is suitable for this simple experiment with a typical red indicator LED.

3.4 How the Blinking Process Works

The Arduino follows a sequence of instructions programmed by the user.

For this experiment:

  1. Arduino starts running the uploaded program.
  2. Digital pin 8 is configured as an output.
  3. Arduino sets digital pin 8 HIGH.
  4. The LED turns ON.
  5. Arduino waits for 1,000 milliseconds.
  6. Arduino sets digital pin 8 LOW.
  7. The LED turns OFF.
  8. Arduino waits for another 1,000 milliseconds.
  9. The process repeats continuously.

One thousand milliseconds equals one second.

The complete ON/OFF cycle takes approximately two seconds.

This produces a blinking frequency of approximately 0.5 Hz.

Frequency describes how many complete cycles occur every second.

3.5 Understanding the Arduino Program Structure

A basic Arduino program contains two important functions:

setup()

This function runs once when the Arduino starts or resets.

It is used to initialize hardware and configure pins.

loop()

This function runs repeatedly after setup() finishes.

It contains the instructions that the Arduino continuously executes.

In our project, setup() configures pin 8, while loop() controls the blinking LED.

=== 4. CIRCUIT DIAGRAM ===

4.1 Wiring Table

Arduino UNO D8 → 220Ω Resistor terminal 1 (yellow wire)

220Ω Resistor terminal 2 → LED Anode (+) (direct breadboard connection)

LED Cathode (−) → Arduino UNO GND (black wire)

4.2 Step-by-Step Circuit Connections

Step 1: Insert the LED

Place the 5mm red LED onto the breadboard.

Make sure the anode and cathode are inserted into separate, electrically isolated breadboard rows.

Step 2: Connect the Resistor

Insert one terminal of the 220Ω resistor into the same connected breadboard row as the LED anode.

Insert the other resistor terminal into a different row.

Step 3: Connect Arduino Digital Pin 8

Use a male-to-male jumper wire to connect Arduino digital pin 8 to the free terminal of the 220Ω resistor.

Step 4: Connect Ground

Use another jumper wire to connect the LED cathode row to a GND pin on the Arduino UNO.

Step 5: Check the Connections

Confirm that the circuit follows this electrical path:

Arduino D8 → 220Ω Resistor → LED Anode (+) → LED Cathode (−) → Arduino GND

The resistor and LED must be connected in series.

A series circuit is a connection in which components share the same current path.

Source Code

Arduino C++ blink.ino
Source code blink.ino
// Oku Electronics
// Lesson 1: Blinking an LED

const int ledPin = 13;

void setup() {
    pinMode(ledPin, OUTPUT);
}

void loop() {
    digitalWrite(ledPin, HIGH);
    delay(1000);

    digitalWrite(ledPin, LOW);
    delay(1000);
}

Connection Images

Code Explanation

const int ledPin = 13; gives pin 13 a readable name.

pinMode(ledPin, OUTPUT); runs once in setup() and configures the pin as an output.

Inside loop(), digitalWrite() switches the pin HIGH or LOW and delay(1000) waits one second (1000 milliseconds).

Expected Results

After uploading, the LED turns on for one second and off for one second, repeatedly. The on-board LED marked “L” blinks at the same time because it is also connected to pin 13.

Troubleshooting

Problem: LED does not blink

Possible causes

  • LED connected backwards
  • Wrong Arduino pin
  • Loose jumper connection
  • Incorrect resistor placement
  • Program not uploaded

Solution

Check the connection diagram. The longer LED leg (anode) goes towards pin 13 through the resistor. Confirm that the correct board and port are selected in the Arduino IDE, then upload again.

Problem: Upload fails with a port error

Possible causes

  • USB cable is charge-only
  • Wrong port selected
  • Another program is using the port

Solution

Use a data USB cable, choose Tools → Port again, and close Serial Monitor windows in other programs.

Summary

You learned how to configure an Arduino digital output, connect a current-limiting resistor, and control an LED using HIGH and LOW signals. This simple project is the foundation for many other Arduino projects.