Overview
Every Arduino sketch has two functions. setup() runs once after power-up or reset;
loop() then runs again and again forever. This sketch uses them to blink the LED that is already
on the board, so you need no other parts.
You will need
- Arduino Uno R3 and a USB data cable (some cables carry power only)
Wiring
| Uno pin | Connects to | Notes |
|---|---|---|
| 13 (LED_BUILTIN) | On-board L LED | Already connected on the board; nothing to wire. |
Uploading
- Install the Arduino IDE from the official download page.
- Connect the board, then choose Tools → Board → Arduino Uno and the matching Port.
- Paste the sketch and click Upload (the right-arrow button). The TX and RX lights flicker while it transfers.
If the upload fails, go to Fixing upload errors.
Diagram
The sketch
// Blink the on-board LED once per second.
void setup() {
pinMode(LED_BUILTIN, OUTPUT); // pin 13 on the Uno
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // LED on
delay(500); // wait half a second
digitalWrite(LED_BUILTIN, LOW); // LED off
delay(500);
}How the code works
LED_BUILTIN is a constant the board package defines, so the same sketch works on boards
whose LED is on a different pin. delay() pauses the whole program; that is fine here, and
millis() timing shows how to wait without stopping everything else.
What you should observe
- The LED marked L blinks: half a second on, half a second off.
- Change both 500s to 100 and upload again: it blinks five times faster.