Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

Automaton

Reactive state machine framework for Arduino

The Automaton framework allows you to create Arduino applications that consist entirely of concurrently running components (finite state machines) interacting with one another. Changes are automatically propagated through the application like changes in a spreadsheet.

Automaton components can trigger each other and form intricate control structures. Automaton helps you create your own components, makes them interact with the bundled components to let you control whatever your Arduino or its peripherals are capable of doing.

Comes with bundled state machines for timers, leds, analog inputs, comparators, logical operations, buttons, rotary encoders and a music/pattern sequencer.

Extensive documentation, tutorials and code available at:

https://github.com/tinkerspy/Automaton/wiki

Sample code

This simple example demonstrates the use of a led component with a button component to toggle a blinking led when the button is pressed.


#include <Automaton.h>

// Toggle a blinking led (pin 5) with a button (pin 2)

Atm_led led;
Atm_button button;

void setup() {

  led.begin( 5 )
    .blink( 200, 200 ); // Set up a led to blink 200ms/200ms

  button.begin( 2 )
    .onPress( led, led.EVT_TOGGLE_BLINK ); / Toggle the led when button pressed

}

void loop() {
  automaton.run();
}

Download

Get the Automaton via the Arduino library manager, platformio or the installation page: https://github.com/tinkerspy/Automaton/wiki/Installation

Features

  • Cooperative multi tasking state machine base class for building your own components
  • Components are table based state machines, you define the behavior using just a little coding
  • Lightweight machine scheduling class
  • Built in state timers and counters
  • Communication between components via event triggers, connectors and direct method calls.
  • Sleep states to save microcontroller cycles
  • Debugging (state monitor) tracing that lets you see what the components are doing
  • Encourages modular design and separation of concerns
  • Components you create can be shared as stand alone Arduino libraries (dependent only on the Automaton library)
  • Machine template editor to help you create your own state machines

Extensions

  • Automaton Servo extension
  • Automaton esp8266 extension
  • Automaton Adafruit RGBLCDShield extension

More: https://github.com/tinkerspy/Automaton/wiki/Contributed

Documentation & tutorials

Documentation for the (Automaton & Machine) base classes and the bundled components is available in the Github wiki: https://github.com/tinkerspy/Automaton/wiki

If you want to make your own components, which is where the real fun is, look at the machine building tutorial:

tinkerspy@myown.mailcan.com