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.