-
Notifications
You must be signed in to change notification settings - Fork 64
Home
Automaton is an event driven framework that allows you to create Arduino applications that consist entirely of concurrently running state machines interacting with each other.
Features
- Cooperative multi tasking finite state machines base class for building your own state machines
- State machines are table based, you define the behavior using just a little coding
- Lightweight machine scheduling class with priorities
- Built in state timers (with milli- and microsecond resolutions) and counters
- Communication between machines via a messaging queue or direct machine method calls.
- Sleep states to save microcontroller cycles
- Pin state monitor
- Debugging (state monitor) hooks (that let you see what the machines are doing)
- Encourages modular design and separation of concerns
- State machines you create can be shared as stand alone Arduino libraries (dependent only on the Automaton library)
- A small footprint version of the state machine and factory classes is available to run multiple machines on even the tiniest of Arduinos.
Documentation for the (Factory & Machine) base classes and the bundled state machines is linked in the textbox on the right. If you want to make your own machines, which is where the real fun is, look at the machine building tutorial.
#include <Automaton.h>
#include <Atm_fade.h>
#include <Atm_button.h>
// Four state machines: Two buttons trigger two fading leds
Atm_fade led1, led2;
Atm_button button1, button2;
Factory factory;
void setup()
{
// Initialize two buttons on pins 11 and 12
button1.begin( 11 );
button2.begin( 12 );
// And two fading leds on PWM pins 3 & 5
led1.begin( 3 ).blink( 500 ).fade( 5 ).repeat( 1 );
led2.begin( 5 ).blink( 500 ).fade( 5 ).repeat( 1 );
// Tell the buttons to send a message to the leds when pressed
button1.onPress( &led1, led1.MSG_BLINK );
button2.onPress( &led2, led2.MSG_BLINK );
// Add the machines to a multitasking factory
factory.add( led1 ).add( led2 ).add( button1 ).add( button2 );
}
void loop()
{
factory.cycle(); // And run the factory
}
Base class for defining self contained multi-tasking state machine objects.
Add your state machines to the factory class, assign them a priority and run them from the Arduino loop().
To get you up and running quickly we've bundled a number of ready to use state machines. Combine them to create your application.
A state machine for handling button presses, longpresses, repeats, debouncing, etc.
A state machine that handles commands coming in over a serial line (Stream), parses and interprets them and fires off a handler callback.
This state machine monitors an analog input with a configurable sample rate and fires off a callback whenever one of a list of thresholds are crossed. Optionally keeps a moving average to smooth out peaks and troughs.
Control a led via a PWM enabled pin. Control blink speed, pause duration, fade in/out slope and number of repeats.
Control a led via a digital pin. Control blink speed, pause duration and number of repeats. Can also be used to control other on/off devices like relays and buzzers.
Monitor a digital pin for incoming pulses, fire a callback or send a message to another machine.
Generate different waveforms (sine, sawtooth, reverse sawtooth, square, triangle) via the analog out pin of a teensy 3.1.
Simple state machine that provides standard timing event functionality. Configure interval and number of repeats. Can be controlled via the message queue. Fires a callback or sends a message via the message queue when the timer triggers. Create timers of up to 136 years.