All projects
2024 Status · Sequenced Build time · ~3 weeks Stack · Arduino Nano · LEDs · button input

Arduino Powered Traffic Lights

A small intersection controller that cycles red, amber, and green lights with predictable timing, plus a pedestrian request button that waits for the safe point in the sequence.

STATE MACHINE RED 5 seconds AMBER 2 seconds GREEN 5 seconds BUTTON queued Pedestrian WAIT

What it is

A model traffic-light controller. The Arduino moves through red, amber, and green states with fixed timing, then checks whether someone pressed the pedestrian button before deciding the next safe action.

Why I built it

Traffic lights look simple until you try to code them cleanly. A beginner version can be made with a few delay calls, but that blocks everything else. I wanted the better version: readable logic, button input, and timing that can keep running while the Arduino listens.

What's inside

  • Three LED outputs for red, amber, and green.
  • A pedestrian button wired with a pull-down resistor.
  • A state enum that tracks which light is active.
  • millis-based timing so the loop stays responsive.

What I learned

The main lesson was avoiding delay. Once delay is gone, the code feels more like a real controller: it can keep checking input, update the current state, and make decisions without freezing the whole program.

I also learned why small projects are perfect for practicing structure. A traffic light is simple enough to finish, but still has enough rules to punish messy code.

What I'd do differently

The next version would control a full four-way intersection with two traffic directions, pedestrian walk signals, and an emergency override input. That would turn the simple sequence into a proper coordination problem.

"The project that taught me delay is a trap."

Got a small control-system idea?

The good ones usually start with three LEDs and a rule that gets more interesting.