After learning about Arduino, breadboards and resistors, it is time to write your first program and control an electronic component.
We will start by blinking the built-in LED on an Arduino Uno R3, then move to an external LED on a breadboard. You will learn to upload a program, understand its instructions and change the blink rate.
What do you need?
| Component | Use |
|---|---|
| Arduino Uno R3 board | Run the program |
| USB data cable | Connect the board to the computer |
| Computer with Arduino IDE | Write and upload the program |
| Breadboard and jumper wires | For the external circuit |
| Red LED and 330 Ω resistor | For the external circuit |
Start with the built-in LED: No external connections are needed for the first part.
Step 1: connect the board

Connect the Arduino to your computer using USB, then open Arduino IDE.
Select the board type Arduino Unoand its communication port. The interface varies by software version, but these options are in the board selector or Tools.
If the board does not appear, check that your cable supports data; some USB cables are for charging only.
Step 2: write the program
Create a new sketch and replace its contents with this code:
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
Click Verify to check the code, then Upload to upload it to the board.
After uploading, the built-in LED should light for one second and turn off for one second, repeating continuously.
How does the code work?
The setup() function
Runs once when the board starts or resets.
This instruction sets the LED pin as an output:
pinMode(LED_BUILTIN, OUTPUT);
Name LED_BUILTIN refers to the built-in LED pin defined by the selected board.
The loop() function
Repeats continuously after setup().
This instruction turns on the LED in the Uno R3 experiment:
digitalWrite(LED_BUILTIN, HIGH);
The program then waits 1,000 milliseconds, or one second:
delay(1000);
It then turns off the LED, waits another second and repeats the cycle.
Note: During delay() , subsequent instructions in the main program flow wait; later, we will learn timing methods that do not block other tasks.
Step 3: change the blink rate
Replace both 1000 values with 250, then upload the program again.
The LED will turn on for a quarter of a second and off for a quarter of a second.
Also try different on and off durations:
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(200);
digitalWrite(LED_BUILTIN, LOW);
delay(800);
}
Here, the LED is on briefly and remains off for longer.
Step 4: control an external LED
Disconnect USB before wiring. We will use digital pin D8 to control the external LED.
| Terminal | Connection |
|---|---|
| Pin D8 | To one end of a 330 Ω resistor |
| The other resistor lead | To the LED's positive lead |
| LED negative lead | To GND |
Place the LED leads in separate breadboard groups and check polarity before reconnecting power.
The resistor is in series with the LED to limit current. A 330 Ω resistor suits this experiment with a standard red LED and 5V logic, subject to the component specifications.
Use the following code:
const int ledPin = 8;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
Reconnect USB and upload the program. You can now control an external LED through code.
What if the experiment does not work?
| Problem | What to check |
|---|---|
| The board does not appear in the software | Data cable, USB port and the correct board driver |
| Program upload fails | Selected board and port, and the error message |
| The built-in LED works but the external one does not | LED polarity, resistor and wire positions |
| The external LED stays on without blinking | Check its D8 connection and confirm the new code uploaded successfully |
| The circuit stops working after a change | Disconnect power and check every connection individually |
Test the built-in LED first. Success helps confirm communication and uploading before you troubleshoot the external circuit.
Small challenge: create your own lighting pattern
Change the program to blink three times quickly, then pause for two seconds before repeating.
You can do this by repeating on and off instructions. The goal is to understand instruction order and how timing affects the result.
You have progressed from assembling components to controlling them with code. Next, make the circuit respond to an input such as a push button instead of a fixed pattern.
RAQAMYAT — from an idea to your first project.

