• Work-to-date

    Chris12/16/2014 at 08:05 0 comments

    I started playing with the idea of a state machine a few weeks ago and at this point I have a functional one. Not surprisingly, The states of the machine are modelled as c++ object instances with the type of state defined by the class of the object.

    I am a big fan of interpreted languages (like python) for this kind of stuff but I do not imagine you could get a lot done with a python interpreter loaded on an Arduino. I did want the flexibility of being able to define states easily and potentially dynamically. To that end the state machine loads itself from an XML definition (I used TinyXML to parse this definition).

    Loading state from XML is kind-of interesting ... while testing the basic state machine I was loading the states dynamically from the serial monitor ... it raises interesting possibilities for re-programming the device remotely.

    There is definitely an overhead cost to parsing the XML and maintaining a hierarchy of state objects ... it works well but this whole idea may need to be optimized or totally re-evaluated for memory consumption if the device gets very sophisticated.

    So far I have a few states (for testing):

    • A menu state that is a holder allowing navigation through a hierarchy of states,
    • An LCD backlight state for toggling the display backlight
    • An LCD Test state that runs through the capabilities of the LCD display.
    The hardware so far consists of:
    • Trinket
    • 2x16 LCD display (salvaged from a previous project)
    • 3 buttons (taken from a PS-2 mouse)
    • an 8 ohm speaker + resistor (taken from a cordless phone)
    • 9 volt battery connector
    I also have access to (that I can think of):
    • 4 pin RGB led's
    • older bluetooth shield,
    • temperature sensor,
    • motion sensor
    My goal is to use mostly scavenged parts for this project; this limits functionality and definitely means I will not be making a watch. However, I can definitely fit all of these parts and a bit more in a small-enough case for this contest ... the question is what will this device do?