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.
| Equal on/off phase | Approximate full cycle |
|---|---|
| 250 milliseconds | 500 milliseconds |
| 500 milliseconds | 1 second |
| 1000 milliseconds | 2 seconds |
4. Troubleshoot in a fixed order
| Problem | Next check |
|---|---|
| No port appears | Try a known USB data cable and check the board connection and required driver. |
| Compilation fails | Read the first compiler error; check braces, semicolons and the selected board package. |
| Upload fails | Confirm the board and port selection, then check the IDE's upload error details. |
| Only a steady light is visible | Identify the programmable LED rather than the power indicator; confirm the latest sketch uploaded. |
| A different board behaves differently | Check 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
- Arduino: Blink on UNO Rev3
Official built-in LED example and explanation.
- Arduino: digitalWrite
Reference for digital output states and pin configuration.
- Arduino: Blink Without Delay
A next step for timing an output while continuing other work.
Project questions
Frequently asked questions
Practical answers to help you choose the next step.
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 guideCompetition 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