Ryan McLaughlin | Mechatronics Portfolio
405 Lab 0x01: Vendotron

Code Documentation:

  • Vending Machine Simulator (vendotron.py): Vendotron Source Code

    The first project of ME 405 consisted mainly of Python review and the introduction of generators. In the past, finite state machine implementation was based on a "run" method within a class. However, using a generator and the next() method of a generator, we can achieve a more straightforward finite state machine structure.

    In terms of the actual program functionality, as is described in more detail as a part of the file documentation (see vendotron.py), this program simulates a simple vending machine. It has four different drink choices, the ability to add money through various denominations, and a simple user-interface in the Spyder console. Some of the main learning outcomes from this lab were:
  • Reviewing the use of keyboard keys (numbers for adding money and letters for drink selection/other options) as interupts
  • Working with dictionaries and the various available methods for working with them
  • Learning to effectively use a generator and the next() method
    To demonstrate how a user would interact with this program, see the annotated image below for one example of user interaction:

    Figure 1.1. Example console readout for putting in money, buying two drinks and getting money back through ejection interupt.



    Note that this is only one simple example, and that many other possible paths of operation are available.

    Click here for the next lab, 405 Lab 0x02: Reaction Times.