LAB 002
External LED: Build the Circuit
Recreate blink with a breadboard LED, its resistor and a wire to digital pin 8.
01
What you will build
An LED on D8 that blinks one second on, one second off.
Why it matters
The output circuit you used in Lab 1 is now visible and physically editable.
What you will learn
- breadboard rows and common ground
- anode, cathode and current-limiting resistor
- GPIO pin mapping
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.
- An 830-contact solderless breadboard joins inserted leads through hidden spring strips so circuits can be rebuilt without solder. Full-size rectangular board, center channel, numbered five-hole terminal groups and side power rails. Counted contact holes are not component units.
- An assortment of discrete indicator LEDs provides several visible colors for status and display experiments. Loose two-lead lens packages of different tints; transparent lenses can emit several different colors.
- A mixed resistance assortment supplies values for current limiting, biasing and divider experiments. Groups of axial two-lead resistors; use labeled storage and measure uncertain parts out of circuit.
- Male-to-male jumper leads make removable point-to-point connections for low-current prototype signals. Pins at both ends; count individual leads rather than ribbon groups. Check intact insulation and snug contacts before use.
- 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
Disconnect USB before changing breadboard wiring; check connections before reconnecting.
Use one 220–330 Ω resistor in series with each ordinary LED. Never connect 5V directly to GND.
- 01
Disconnect the Uno USB cable. Identify which breadboard holes are connected internally (typically groups of five on either side of the center gap). Place the LED with its two legs in different, unconnected groups; identify the anode (usually the longer leg) and cathode (usually the shorter leg or flat side).
- 02
Place a verified 220–330 Ω resistor so its two legs occupy different electrical groups. Arrange one resistor leg in a group that connects to the LED anode, without putting both resistor legs in the same group.
- 03
Use a jumper to connect Uno D8 to the breadboard group containing the resistor’s free leg. Connect the LED cathode to Uno GND, directly or through a ground rail you have confirmed is connected to GND.
- 04
Before reconnecting USB, trace the full path D8 → resistor → LED anode → LED cathode → GND. Check polarity, resistor value and breadboard groups; the resistor must not be bypassed, and the circuit must not directly connect 5V to GND.
- 05
Select Blink on D8, place its complete code in src/main.cpp, then Save, Build and Upload. Observe two full blink cycles; change one delay and test again.
| From | To | Purpose / notes |
|---|---|---|
| Uno D8 | LED 1 series resistor 220–330 Ω | Drive output with current limitingPut the resistor in series, never across 5V and GND. |
| LED 1 series resistor | LED 1 anode (long leg) | Feed LED in forward directionResistor may instead go on the cathode side if it stays in series. |
| LED 1 cathode (short leg/flat side) | Uno GND | Complete the circuitLED must not be connected directly across 5V and GND. |
Predict before you run
- What happens if the LED is reversed while power is disconnected and restored only after inspection?
- If D8 becomes D9 in code alone, will this LED blink?
External LED on D8 alternates on and off; resistor stays in series.
- Observe two full blink cycles.
- Check that changing code timing changes this external LED.
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
#include <Arduino.h>
// D8 -> series resistor -> LED anode; cathode -> GND.
// A variable name lets us refer to D8 consistently; the wire must actually be connected to D8.
const int ledPin = 8;
// Unlike LED_BUILTIN, this output controls the LED you wired on the breadboard.
void setup() {
// Tell the microcontroller that D8 will send a signal rather than read one.
pinMode(ledPin, OUTPUT);
}
void loop() {
// D8 goes HIGH and current flows through the resistor and LED when wired correctly.
digitalWrite(ledPin, HIGH);
delay(1000);
// D8 goes LOW to switch the external LED off.
digitalWrite(ledPin, LOW);
delay(1000);
}
Experiments & challenges
- Change only the delay; restore it.
- Power off, move the signal wire from D8 to D9, then upload the matching pin-9 variant.
Scale it up
Optional two-LED alternating circuit adds a second LED and its own resistor; a function variant then packages one blink.
Challenge
Sketch your own safe circuit route and explain where current flows while D8 is HIGH.
Advanced implementation
What to remember
- Why is a resistor necessary in series?
- The resistor limits current through the LED and the GPIO output. An LED alone does not safely limit its own current; keep the resistor in series, whether it is before or after the LED.
- Which breadboard holes share an electrical node?
- Each five-hole terminal strip on one side of the breadboard center gap is one electrical node. The opposite side of the gap is separate. Power rails can have breaks, so check the board markings and continuity with power disconnected.
Learning summary
A GPIO output can drive a properly current-limited external LED when the circuit returns to GND.
Lab 3 repeats this same circuit pattern for multiple independently timed outputs.
Troubleshooting
No upload or no power
Check USB data cable, selected PlatformIO Uno environment and upload port; verify the power LED.
Unexpected external LED behavior
Disconnect USB, check the breadboard row, LED polarity, series resistor, GND, then compare the code pin with the wire.
LED stays dark but onboard L blinks
Verify code drives D8, not LED_BUILTIN; inspect the resistor path and LED orientation.