🥤 Vending Machine FSM

Moore Machine — Accepts coins until price met, then dispenses

State Diagram (Price: 15¢)

S0 0¢ S5 5¢ S10 10¢ S15 15¢+ DISPENSE S5 --> N(5¢) S10 --> D(10¢) S10 --> N(5¢) S15 --> D(10¢) S15 --> N(5¢) S15 (with change) --> D(10¢) +5¢ change S0 --> dispense / reset S0 (simplified, shown as note) --> * Refund returns to S0 from any state
Moore Machine Outputs
Each state represents the accumulated amount. The machine only dispenses when reaching S15 (15¢ or more). Overpayment returns change.

Inputs: N = Nickel (5¢), D = Dime (10¢)

Vending Machine

🥤
Refreshing Soda
15¢
$0.00
Insert coins...
Insert Coin
Change Return
—
Current State
S0 (0¢) — Waiting for coins. Need 15¢ total.
State Amount +5¢ +10¢
S0 0¢ S5 S10
S5 5¢ S10 S15
S10 10¢ S15 S15
S15 15¢+ DISPENSE → S0