LAB 001
Onboard LED: First Blink
Upload a program that switches the LED already on the Uno on and off.
01
What you will build
A one-second on, one-second off built-in LED blink.
Why it matters
The board responds to instructions you write and upload.
What you will learn
- program, setup and loop
- digital output and HIGH/LOW
- timing with delay
02
Parts List
- Arduino Uno R3 is a 5 V ATmega328P microcontroller board for direct control of sensors, switches and small driver circuits using a single uploaded program. UNO-format board with USB-B socket, barrel connector, ATmega328P and digital/analog header labels. The canonical Uno R3 is separate from the generic compatible-board record. Identify pins from the board labels/pinout rather than a diagram for a newer Uno generation.
- A USB-A to USB-B cable carries USB power and, when its data conductors are present, a host/device data link. Rectangular USB-A plug at one end and square USB-B plug at the other; standalone purchase length is recorded as ten feet. Inspect the plug shape; micro-USB is not USB-C, and USB-B is the squarer device connector.
03
Assembly
Use only the built-in LED for the core; unplug USB before any later rewiring.
- 01
Connect the Uno R3 with a USB data cable. Open the Uno project in VS Code and confirm the PlatformIO Uno environment and upload port; this lab needs no breadboard wiring.
- 02
Find the onboard LED marked L (not the power indicator). Select the One-second blink program and replace all of src/main.cpp with its complete code, including #include <Arduino.h>. Predict what HIGH and LOW will do.
- 03
Save, Build and Upload in PlatformIO. Confirm the upload succeeded, then watch the L LED turn on for about one second and off for about one second.
- 04
Change just one delay(1000) value to delay(500), then Save, Build and Upload again. Compare the new pattern with the original.
Predict before you run
- Before upload, will the LED marked L be on continuously or alternate?
- What changes if the first delay doubles?
LED marked L alternates on and off, about one second each.
- Watch two complete on/off cycles.
- Change a delay and confirm the period changes after upload.
04
Code
Arduino Uno R3
Replace src/main.cpp with one complete example. Save → Build → Upload. These labs need no external libraries.
Copy the Uno platformio.ini
[env:uno]
platform = atmelavr
board = uno
framework = arduino
monitor_speed = 9600
// Arduino.h is the main Arduino core header. It makes pinMode(), digitalWrite(), delay(), and
// constants such as HIGH available.
#include <Arduino.h>
// Blink the LED already wired onto the Uno.
// void means this function returns no value. setup() runs once when the board starts or resets.
void setup() {
// LED_BUILTIN refers to the onboard LED pin; OUTPUT allows the board to drive it.
pinMode(LED_BUILTIN, OUTPUT);
}
// After setup(), Arduino calls loop() again and again.
void loop() {
// HIGH sets the output high. On the Uno, that lights the built-in LED.
digitalWrite(LED_BUILTIN, HIGH);
// delay() waits in milliseconds: 1000 ms = 1 second. The program does not do other loop work
// while waiting.
delay(1000);
// LOW sets the output low, turning the LED off.
digitalWrite(LED_BUILTIN, LOW);
// After this second pause, loop() starts over and the LED turns on again.
delay(1000);
}
Experiments & challenges
- Change the on delay only, then restore it.
- Measure roughly how long three complete cycles take.
Scale it up
Try faster, slower, heartbeat and SOS patterns with the same onboard LED; compare repetition with a helper function.
Challenge
Design a recognizable four-flash signal without adding hardware.
Advanced implementation
What to remember
- Which line tells the board which LED to use?
- pinMode(LED_BUILTIN, OUTPUT) configures the onboard LED pin as an output. The digitalWrite(LED_BUILTIN, ...) calls then switch that same pin HIGH or LOW.
- Why does the pattern repeat without copying loop() repeatedly?
- After setup() finishes, the Arduino framework calls loop() repeatedly. When the function reaches its closing brace, it is called again, so the blink sequence repeats.
Learning summary
A digital output changes physical voltage; loop() repeats your instructions.
Lab 2 builds the output circuit yourself on a breadboard.
Troubleshooting
No visible blink
Check the LED marked L rather than the power indicator; confirm PlatformIO upload success, board environment and port.
No upload or no power
Check USB data cable, selected PlatformIO Uno environment and upload port; verify the power LED.