Vending Machine Controller in Logisim-evolution

Alongside the traffic light, the vending machine is one of the classic finite-state-machine course projects: coins go in, the machine tracks the total, dispenses the item, and returns change. It exercises everything — state encoding, D flip-flops, and combinational output logic.

Define the problem first

Keep the spec small enough to finish: the machine accepts 5¢ and 10¢ coins, the item costs 15¢, and it returns change. States track money inserted: IDLE (0¢), GOT5 (5¢), GOT10 (10¢). From GOT10, another 5¢ or 10¢ coin dispenses the item (and returns 5¢ change in the 10¢ case). A reset button returns to IDLE and refunds.

From state diagram to circuit

Step 1 — Draw the state diagram. On paper: circles for IDLE/GOT5/GOT10, arrows for coin inputs (5¢, 10¢), and mark which transitions assert DISPENSE and RETURN5.
Step 2 — Encode and build next-state logic. Two D flip-flops hold the state (00/01/10). Derive the next-state equations from your diagram — by hand with K-maps, or with Project → Analyze Circuit → Build Circuit — and wire them up. See sequence detectors for the same method on a smaller example.
Step 3 — Decode the outputs. DISPENSE and RETURN5 are pure combinational functions of the current state (a Moore machine). A decoder-style AND-OR network works, or reuse the combinational analysis tool.
Step 4 — Test with the clock. Add a Clock, enable Simulate → Ticks Enabled, and “insert” coins with input pins. Watch the state probes advance: 5¢ → 10¢ → dispense. Then try the change case (10¢ + 10¢) and the reset refund.

Go further

This is the same FSM method as our traffic light controller. For a bigger challenge, add a second product with a different price, or a digital lock keypad.