Electronics and coding

Arduino LED Project for Beginners

Blinking the built-in LED on an Arduino UNO Rev3 is a useful first electronics and coding exercise. It lets you practise selecting a board, uploading a program and observing a digital output without assembling an external circuit. This guide uses the UNO Rev3; check your own board's documentation if you use another model.

By Robotic Sir · Learning guide

What you need

  • An Arduino UNO Rev3
  • A compatible USB data cable
  • A computer with Arduino IDE and the appropriate board support
  • A notebook or text file to record your timing experiments

1. Connect the board and select the upload target

Connect the UNO Rev3 to the computer with a USB data cable. In Arduino IDE, choose the UNO board and the port associated with the connected board. Open the built-in Blink example from File → Examples → 01.Basics → Blink.

For this exercise, leave external components disconnected and use the board's built-in LED. The LED_BUILTIN constant identifies the LED pin for the selected board. A power indicator LED is separate from the programmable LED.

2. Upload a short repeating pattern

The following sketch gives the LED two equal phases. The setup function configures the output once. The loop function repeats the on/off pattern. On the UNO Rev3, HIGH turns the built-in LED on and LOW turns it off.

const unsigned long phaseMs = 500;

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

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(phaseMs);
  digitalWrite(LED_BUILTIN, LOW);
  delay(phaseMs);
}
  • Use Verify to check that the sketch compiles for the selected board.
  • Use Upload and wait for the IDE to report completion.
  • Observe the programmable LED: each phase is 500 milliseconds, so one full on/off cycle lasts about one second.

3. Change one value and predict the result

Change phaseMs to 1000, upload again and predict the full-cycle duration before observing the LED. Then try 250. The full cycle contains both an on phase and an off phase, so equal phases of 1000 milliseconds produce a cycle of about two seconds.

Next, replace the two delay values with different durations. For example, an on phase of 200 milliseconds and an off phase of 800 milliseconds still makes a cycle of about one second, but the LED spends less of the cycle lit. Record the code values alongside what you observed.

3. Change one value and predict the result: reference table
Equal on/off phaseApproximate full cycle
250 milliseconds500 milliseconds
500 milliseconds1 second
1000 milliseconds2 seconds

4. Troubleshoot in a fixed order

4. Troubleshoot in a fixed order: reference table
ProblemNext check
No port appearsTry a known USB data cable and check the board connection and required driver.
Compilation failsRead the first compiler error; check braces, semicolons and the selected board package.
Upload failsConfirm the board and port selection, then check the IDE's upload error details.
Only a steady light is visibleIdentify the programmable LED rather than the power indicator; confirm the latest sketch uploaded.
A different board behaves differentlyCheck that board's built-in LED pin, polarity and official example.

5. Connect the exercise to robotics

This project introduces a repeating control sequence: configure an output, change its state and observe the effect. A robot adds inputs and actuators, but keeping a small, testable output exercise is still useful when bringing up a new controller.

The delay function pauses the sketch's normal execution. A robot that must read controls and respond continuously needs a more suitable timing approach, such as the official Blink Without Delay example. For a next electronics build, learn about LED polarity and current-limiting resistors before connecting an external LED; use the board's specifications for voltage and current limits.

References and further learning

Project questions

Frequently asked questions

Practical answers to help you choose the next step.

No. This exercise uses the Arduino UNO Rev3's built-in LED and a USB connection. An external LED circuit is a separate exercise with additional component and wiring requirements.
LED_BUILTIN is the board-defined constant for its built-in LED pin. Select the correct board in the IDE so the example uses the appropriate board definition.
A motor needs an appropriate driver or switching circuit and a suitable power supply. Do not use a controller output pin as the motor's power source; follow the documentation for the chosen motor, board and driver.

Build your understanding

Keep learning with another project

Robot building

Build a Soccer Robot: Beginner Project Guide

Plan a beginner soccer robot: choose compatible parts, assemble a chassis, test motor control and practise ball handling before a competition.

Read the guide

Competition preparation

Robot Race Preparation: Testing Checklist

Prepare for a robot race with a practical checklist for rules, steering, stopping, practice runs, troubleshooting and packing your equipment.

Read the guide