Mini Traffic-Light System

Three LEDs run through a timed red, amber and green sequence.

← All project briefs

Safety and scope

This is a tabletop learning model only; it must not be connected to or used as a real road traffic signal.

Plan, predict and test

Suggested virtual study time: about 15 minutes. This is a planning estimate, not a validated construction time.

Preparation: Foundation electricity and basic programming logic. Adult supervision for children. Review a foundation lesson ↗

Use paper, a spreadsheet or a simulator. This is not a verified physical assembly guide.

  1. Scenario: Trace green 3 s, amber 1 s and red 3 s from the illustrative sketch.
  2. Expected result: Exactly one indicator is on in each stable state.
  3. Checkpoint: Write your prediction, test it in the virtual model and explain any difference.

Knowledge check

Can this demo be installed as a public road controller?

A correct answer does not certify the physical system.

Record your validation

Use only virtual inputs and indicators until the actual components, pinouts and electrical limits have been verified.

CaseWhat to record
Normal inputGreen 3 s → amber 1 s → red 3 s
BoundaryTotal cycle 7 s; verify one output active during stable phases
Missing or invalid inputReset briefly clears outputs. This is an LED sequence, never a road traffic controller.
Repeat testRepeat the virtual test, record the actual output and compare with the expected result.

These are test-planning requirements, not recorded hardware results.

Before building: understand the listed components and the relevant low-voltage safety rules. This is a concept brief, not a tested assembly manual.

What it does

Learn output sequencing, timing and how to avoid blocking the controller while a sequence runs.

Engineering principle

The simplest version uses timed delays. A more flexible implementation uses millis()-based elapsed-time checks so other work can continue while the signal state changes. A sample cycle is green for 5 seconds, amber for 2 seconds and red for 5 seconds.

Hardware and components

  • Arduino Nano or UnoRuns the signal state machine.
  • Red, amber and green LEDsRepresent the three traffic-light states.
  • 3 × 220 Ω resistorsLimit LED current.
  • Breadboard and jumper wiresConnect the prototype.
  • Optional pushbuttonCan be added to request or pause a sequence.

Suggested build sequence

  1. Connect each LED through its own resistor to an output pin.
  2. Write a state table that defines which LED is active in each phase.
  3. Implement the 5 s / 2 s / 5 s timing cycle.
  4. Replace delay() with millis() timing to keep the loop responsive.
  5. Add a pedestrian request or fault indication as a later exercise.

Learning outcomes

  • Digital outputs
  • Timing and finite-state machines
  • Non-blocking code
  • Basic test planning

Possible upgrades

Add a pedestrian crossing, button request, night mode or two-way intersection model.

Practice the core principle

This simplified exercise is not the full physical project shown above. Test in simulation first; verify real hardware against its datasheet. Children need adult supervision.

Reference components

  • Arduino Uno (5 V)
  • 3 LEDs
  • 3 × 330 Ω resistors
  • Breadboard and jumpers

Connection plan

  • D2 → red LED through 330 Ω
  • D3 → amber LED through 330 Ω
  • D4 → green LED through 330 Ω
  • LED cathodes → GND

Reference sketch

const int red=2, amber=3, green=4;
void setup(){
  pinMode(red,OUTPUT);
  pinMode(amber,OUTPUT);
  pinMode(green,OUTPUT);
}
void show(int pin, int ms){
  digitalWrite(red,LOW);
  digitalWrite(amber,LOW);
  digitalWrite(green,LOW);
  digitalWrite(pin,HIGH);
  delay(ms);
}
void loop(){
  show(green,3000);
  show(amber,1000);
  show(red,3000);
}

How the code works

  1. Constants assign pins to three LEDs.
  2. setup configures pins as outputs.
  3. show turns all LEDs off, lights only the selected LED and waits.
  4. loop repeats the green, amber, red sequence.

Practice sequence

  1. With power disconnected, place LEDs and resistors; check polarity.
  2. Connect cathodes to GND and each resistor to its specified output.
  3. Simulate the sketch first, then have an adult check wiring before applying power.
  4. Observe each light separately before checking the whole sequence.

Expected result

Exactly one LED should be on at a time; verify sequence and timing.

Troubleshooting

If an LED is dark, disconnect power and check its polarity, resistor and pin assignment.

Independent challenge

Change the green duration and predict the new cycle period.

Related briefs