LAB 003
Multiple Outputs: A Traffic Signal
Build three copies of the LED circuit and sequence them with explicit instructions.
01
What you will build
Three individually driven LEDs on D8, D9 and D10 in a traffic-light-like sequence.
Why it matters
Repetition in wiring and code motivates loops and arrays after a working simple build.
What you will learn
- multiple independent output pins
- state progression and timing
- repetition, loops and arrays as optional improvements
02
Parts per station
- 1 each An independently programmable Uno R3 per simultaneous station.
- 1 each A small breadboard is a possible substitute after inspection.
- 3 each Ordinary discrete LEDs; colors are optional.
- 3 each One verified 220–330 Ω current-limiting resistor per LED; count and values before class.
- several assorted Count leads usable for the chosen circuit before class.
- 1 each Availability unconfirmed. One working USB-A to USB-B DATA cable for upload; cable length need not be 10 feet. This canonical item is procurement-only, so existing cable stock must be verified, not assumed.
Station planning and software
Three separately counted Uno R3 boards and four counted 830-point breadboards; fifth complete independent station is unconfirmed. Kit boards and small breadboards may add capacity only after identification and testing. Count usable USB data cables, LEDs, resistors, jumpers and any inputs before meeting. For five-LED variants count five LEDs and resistors per station.
- Arduino IDE or Arduino CLI with Arduino AVR Boards core; select Arduino Uno and the connected serial port.
Arduino IDE is the only required development environment. Arduino CLI is optional.
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 USB; copy the Lab 2 circuit three times, one series resistor per LED.
- 02
Connect LED 1 to D8, LED 2 to D9 and LED 3 to D10; connect all cathodes to Uno GND.
- 03
Check rows, polarity and three resistors; reconnect, verify and upload the core sketch.
- 04
Name each visible phase aloud; change one phase delay only.
| 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. |
| Uno D9 | LED 2 series resistor 220–330 Ω | Drive output with current limitingPut the resistor in series, never across 5V and GND. |
| LED 2 series resistor | LED 2 anode (long leg) | Feed LED in forward directionResistor may instead go on the cathode side if it stays in series. |
| LED 2 cathode (short leg/flat side) | Uno GND | Complete the circuitLED must not be connected directly across 5V and GND. |
| Uno D10 | LED 3 series resistor 220–330 Ω | Drive output with current limitingPut the resistor in series, never across 5V and GND. |
| LED 3 series resistor | LED 3 anode (long leg) | Feed LED in forward directionResistor may instead go on the cathode side if it stays in series. |
| LED 3 cathode (short leg/flat side) | Uno GND | Complete the circuitLED must not be connected directly across 5V and GND. |
Predict before you run
- Which LED comes after D8, and for how long?
- What happens if two phases are given the same HIGH state?
Only one of the three LEDs is on at a time: D8, then D9, then D10.
- Observe at least two complete three-phase cycles.
- Confirm each named pin controls its expected LED.
04
Code
After the first LED turns off, the second phase lights D9.
// Labels are roles; actual LED colors may differ.
const int redLed = 8;
const int amberLed = 9;
const int greenLed = 10;
void setup() {
pinMode(redLed, OUTPUT);
pinMode(amberLed, OUTPUT);
pinMode(greenLed, OUTPUT);
}
void loop() {
digitalWrite(redLed, HIGH);
digitalWrite(amberLed, LOW);
digitalWrite(greenLed, LOW);
delay(1000);
digitalWrite(redLed, LOW);
digitalWrite(amberLed, HIGH);
delay(500);
digitalWrite(amberLed, LOW);
digitalWrite(greenLed, HIGH);
delay(1000);
digitalWrite(greenLed, LOW);
}
About this version
core · Arduino Uno R3 · beginner
Show all three physical output branches and straightforward repeated commands.
Same core wiring.
Hardware and wiring for this sketch
- arduino uno r3 · 1 eachAn independently programmable Uno R3 per simultaneous station.
- 830 point solderless breadboard · 1 eachA small breadboard is a possible substitute after inspection.
- assorted leds · 3 eachOrdinary discrete LEDs; colors are optional.
- resistor assortment · 3 eachOne verified 220–330 Ω current-limiting resistor per LED; count and values before class.
- jumper wire assortment · several assortedCount leads usable for the chosen circuit before class.
- 10 foot usb a to usb b cable · 1 eachOne working USB-A to USB-B DATA cable for upload; cable length need not be 10 feet. This canonical item is procurement-only, so existing cable stock must be verified, not assumed.
| 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. |
| Uno D9 | LED 2 series resistor 220–330 Ω | Drive output with current limitingPut the resistor in series, never across 5V and GND. |
| LED 2 series resistor | LED 2 anode (long leg) | Feed LED in forward directionResistor may instead go on the cathode side if it stays in series. |
| LED 2 cathode (short leg/flat side) | Uno GND | Complete the circuitLED must not be connected directly across 5V and GND. |
| Uno D10 | LED 3 series resistor 220–330 Ω | Drive output with current limitingPut the resistor in series, never across 5V and GND. |
| LED 3 series resistor | LED 3 anode (long leg) | Feed LED in forward directionResistor may instead go on the cathode side if it stays in series. |
| LED 3 cathode (short leg/flat side) | Uno GND | Complete the circuitLED must not be connected directly across 5V and GND. |
How the code works
Lines 18–18
After the first LED turns off, the second phase lights D9.
Show all three physical output branches and straightforward repeated commands.
How it works
Repetition in wiring and code motivates loops and arrays after a working simple build.
Repeated physical outputs have repeated setup and control logic; abstraction becomes useful as output count grows.
Experiments & challenges
- Change only the middle phase duration.
- Swap the positions of two LEDs with USB disconnected, then predict which physical position lights first.
Scale it up
Optionally expand to five LED/resistor branches on D8–D12; compare explicit code, a loop and a pin array.
Challenge
Write a three-phase pattern with two LEDs illuminated briefly; explain how to avoid accidental simultaneous high states.
Advanced implementation
Open an advanced sketch in the code selector above. Compare its structure, hardware, and annotated lines with the core sketch.
- Loop with adjacent pins: Use a loop because five pins are consecutive.
- Pin array sequence: Keep chosen pin mapping in an array and iterate.
Check your understanding
Which repeated instruction would you put in a loop?
What does an array let you change in one place?
Learning summary
Repeated physical outputs have repeated setup and control logic; abstraction becomes useful as output count grows.
Lab 4 replaces a fixed timed sequence with behavior controlled by a human button.
Troubleshooting
No upload or no power
Check USB data cable, selected Uno board and serial 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.
Wrong phase or two lights on
Compare D8/D9/D10 wire labels with pin constants and verify all three outputs are reset LOW between phases.