A vending machine controller

The problem

Design a finite state machine for a machine that sells one item for 15 cents and accepts nickels (5) and dimes (10), with no change given, and build a program that simulates it.

Requirements

Technologies

Step by step

  1. List the states and the inputs (nickel, dime), and decide whether the machine is Moore or Mealy.
  2. Fill in the state table completely, for every state and every input.
  3. Code the table as a dictionary and write the loop that follows it.
  4. Test with sequences such as nickel, nickel, nickel and dime, nickel, and check the outputs by hand.
  5. Write the table as truth tables for the next-state bits and simplify them with Karnaugh maps.

Expected result

A simulator that dispenses exactly when 15 cents or more are inserted, with a state table and a K-map for each next-state bit.

How it is evaluated

Ways to improve it