Three states, three lights
A basic traffic light cycles through exactly three states — Green, Yellow, Red — always in the same order, always advancing on some timing signal. Because each light's on/off pattern depends only on which state the machine is in, and never on any additional input, this is a textbook Moore machine.
Encoding the states
Two bits are enough for three states:
- Green = 00, Yellow = 01, Red = 10 (the fourth combination, 11, is simply unused) — stored in a 2-bit register.
- Next-state logic: Green (00) → Yellow (01), Yellow (01) → Red (10), Red (10) → Green (00) — three transitions wired directly from the current state bits back into the register's input through a small block of gates, or a PLM block configured with exactly this truth table.
Output logic: state to lights
Each of the three LEDs is simply a Boolean function of the two state bits — Green = ¬S1·¬S0, Yellow = ¬S1·S0, Red = S1·¬S0 — the exact same one-hot-decode structure as a decoder, since a Moore machine's output logic is nothing more than combinational logic reading the state register.
Try it yourself
Build the 2-bit state register and next-state logic in the circuit editor, drive its clock from a slow CLOCK element, and wire the three output equations to three LED elements — watch them cycle Green, Yellow, Red, Green in a loop exactly as a real traffic light does.