Back to portfolio
Case study · Founder-built

Discrete Logic Traffic Controller

A working multi-phase traffic light controller built end to end with discrete electronics. Every red, yellow, green, and arrow transition is decided by analog comparators and CMOS logic gates, with no microcontroller and no firmware in the loop.

Timing
555 sawtooth
Logic
4081 + 4069
Drivers
LM317 + IRF510
Firmware
None
Subsystems

Five circuits, one working signal

Click any schematic to expand. In the lightbox, click the image again or press the 1:1 button to switch to native pixel size and read fine print.

Diagram 1

Main controller

The brain of the system. A continuously rising voltage from a 555 timer is compared against fixed thresholds; whichever thresholds the voltage has crossed at any moment determines which lights should be on. Logic gates combine those decisions into the right colour for the main road and the cross street.

Diagram 2

Phase-transition blackout

Right before each light changes, every driver is briefly turned off so the next colour comes on cleanly. A 130-millisecond pulse, derived from the same timing signal, gates all the drivers off at once and prevents two colours from showing at the same time.

Diagram 3c

Per-colour LED driver

Every red, yellow, green, and arrow LED has its own dedicated driver. An LM317 regulator sets the right voltage for that LED, and an IRF510 MOSFET switches it on or off under control of the main board.

Diagram C

Battery and power rail

Two LM2937 regulators in parallel convert the 7.4 V Li-Ion battery down to a clean, current-capable 5 V rail. A small comparator circuit lights a red or green LED depending on whether the battery is low or charged, so battery state is visible at a glance.

Diagram 4

Sound-activated on/off

Clap once near the microphone to turn the controller on, clap again to turn it off. A monostable flip-flop debounces the audio pulse, an SN7476 latch holds the on/off state, and a pair of MOSFETs cuts power to the whole controller when off.

How it works

A clock built out of voltage

If you've ever wondered what's actually inside a microcontroller, this project is one answer.

The controller cycles through traffic light phases on a fixed schedule. Instead of running a software loop, a 555 timer chip produces a slowly rising and falling voltage — a sawtooth signal that repeats every few seconds.

Op-amp comparators watch this sawtooth and trip on the moment it crosses a particular voltage. By picking a different threshold for each comparator, you get a different "moment in the cycle." One comparator fires at the start of red, another at the end of red, another in the middle of green, and so on.

AND and NOT logic gates combine those moments into the right colour for each direction. The output of each gate goes to a dedicated LED driver that holds its colour at the correct brightness regardless of battery state.

A small helper circuit briefly turns every driver off for 130 milliseconds between phases so the old and new colours never overlap. A separate clap-detection circuit lets you turn the entire controller on and off without any switch.

Engineering challenges solved

The non-obvious parts

Discrete logic looks simple from the outside. These five decisions are what separate a working signal from a flaky one.

Reliable timing without firmware

A single 555 oscillator drives the entire phase sequence. No clock crystal, no ISR, no firmware loop. The timing reference is one capacitor charging through one resistor.

Clean phase transitions

A 130-millisecond all-off pulse between phases prevents the old colour and new colour from ever being lit at the same time, even briefly.

Constant LED brightness as the battery discharges

Per-channel LM317 linear regulators hold each LED at its rated voltage from full-charge to cut-off, so the lights don't visibly dim as the Li-Ion drops from 8.4 V to 6 V.

Battery state visible at a glance

A two-comparator window detector lights red below 6.3 V and green above 7.1 V. No gauge, no display, just a colour you can see across the room.

Zero standby drain

When the user claps the system off, MOSFETs physically cut the controller's ground from the 5 V rail. The battery only powers the wake-up amp and the latch, drawing well under a milliamp.

Why no microcontroller

Building it the hard way, on purpose

A traffic controller built on a microcontroller is a one-line problem. Built on discrete logic, it's an exercise in actually understanding what a microcontroller does.

There's no firmware in this system, which means there are no bugs in firmware, no compile-flash-debug loop, no boot delay, and no failure modes from corrupted memory or runaway code. Every signal can be probed with a multimeter and explained in one sentence.

For some real products — industrial timers, low-volume one-offs, safety interlocks where every transition has to be certifiable — discrete logic is genuinely the right answer. It's predictable at the gate level, immune to software supply chain issues, and runs forever without updates.

Mostly, the project was about proving the thinking behind hardware, not avoiding microcontrollers in production. Every production design decision — when to use an MCU, when to use an FPGA, when to drop down to discrete logic — gets sharper once you've built the thing without a controller at least once.

Need custom hardware designed?

From discrete-logic systems like this one to firmware-driven products, scoped, designed, and shipped by one engineer.