A clock, a counter, and a decoder cycle three lamps like a street-corner signal. A ready-made fun circuit you can open in the TorchAnvil simulator.
A real traffic controller is, under all the weatherproofing, a little state machine: something counts, something decodes the count into "which lamp is on," and a clock keeps it marching. This sample builds the smallest honest version of that. A 2-bit counter cycles through four states; a decoder turns each state into a single lamp; an OR stitches two of the states together so red gets two slots in the cycle.
The counter is two T flip-flops in the familiar ripple pattern:
(C1, C0) counts 00, 01, 10, 11, 00….Then a tiny 2-to-4 decoder turns that count into four state lines
Y0…Y3, one per combination of C1 and C0:
Y0 = !C1 · !C0 — state 0Y1 = !C1 · C0 — state 1Y2 = C1 · !C0 — state 2Y3 = C1 · C0 — state 3Finally the outputs:
| tick | C1 | C0 | state | lit |
|---|---|---|---|---|
| 0 | 0 | 0 | Y0 | Red |
| 1 | 0 | 1 | Y1 | Green |
| 2 | 1 | 0 | Y2 | Yellow |
| 3 | 1 | 1 | Y3 | Red |
| 4 | 0 | 0 | Y0 | Red (wrap) |
Counter plus decoder plus output logic is the template for basically every hardware sequencer you'll ever meet. Washing machines, elevator dispatchers, arcade-cabinet attract-mode animations, even the microcode ROMs inside old CPUs — they all boil down to "advance a counter, look up what to do this tick." Once you've built one, you've built them all.
4. The sequence speeds up but the
ratio between colors stays the same — that's the decoder doing its
job independent of timing.Y3. Red now
lights for one state instead of two; the cycle becomes a plain
three-phase loop with a mystery dark beat. Reconnect it to restore
the extra red.