Skip to content

Instantly share code, notes, and snippets.

View tinkerspy's full-sized avatar

Tinkerspy tinkerspy

  • Rotterdam, Holland
View GitHub Profile
#pragma once
#include <Automaton.h>
class Atm_stepper: public Machine {
public:
enum { IDLE, START, STEP_HIGH, STEP_LOW, LOOP, DONE }; // STATES
enum { EVT_TIMER, EVT_COUNTER, EVT_START, EVT_STOP, ELSE }; // EVENTS
Atm_stepper( void ) : Machine() {};
#include <Automaton.h>
#include "Atm_trafficlight.h"
Atm_trafficlight tl1, tl2;
Atm_button button;
Atm_timer timer;
Atm_led led;
void setup() {
#include <Automaton.h>
Atm_led led1, led2, led3, led4;
Atm_timer timer;
void setup() {
Serial.begin( 9600 );
led1.begin( 4 ).blink( 500 / 14.4, 500 / 14.4 ).start(); // 14.4 Hz
@tinkerspy
tinkerspy / player32bit.ino
Last active November 28, 2016 13:37
Atm_player 32 bit example
#include <Automaton.h>
Atm_player player; // A player machine with 32 bit patterns
Atm_button button1, button2;
// These pins correspond to bitmap positions
const int8_t pin[] = {
4, 5, 6, 7, 8, 9, 10, 11,
12, 13, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
@tinkerspy
tinkerspy / bicycle3.ino
Last active November 27, 2016 21:13
Paul Murray's bicycle challenge implemented in Automaton
#include <Automaton.h>
/*
http://paulmurraycbr.github.io/ArduinoTheOOWay.html
The OP has a bike headlamp. this headlamp has a button that you can press 5 times to cycle
through 5 output settings, and a power switch. the OP would like to have one button to
control it. A long click should turn the lamp on and off, and a short click should cycle
the brightness. Furthermore, when the lamp is turned on, the OP would like the arduino to
cycle the light up to its previous level of brightness. The outputs to cycle the lamp
#include <Automaton.h>
#include <Automaton-Esp8266.h>
// A remote button that turns on the living room light
// Linked to the light node via the mirror component
Atm_esp8266_wifi wifi;
Atm_button button;
Atm_mirror mirror;
#include <Automaton.h>
#include <Atm_esp8266.h>
Atm_esp8266_wifi wifi;
Atm_esp8266_httpd_simple server( 80 );
Atm_led led;
void setup() {
Serial.begin( 9600 );
#include <Automaton.h>
#include <Atm_esp8266.h>
Atm_esp8266_wifi wifi;
Atm_esp8266_httpd_simple server( 80 );
void setup() {
Serial.begin( 9600 );
wifi.begin( "MySSID", "MyPASSWORD" )
.onChange( true, server, server.EVT_START )
#include "Atm_trafficlight.h"
/* Add optional parameters for the state machine to begin()
* Add extra initialization code
*/
Atm_trafficlight& Atm_trafficlight::begin( int pin_g, int pin_y, int pin_r ) {
// clang-format off
const static state_t state_table[] PROGMEM = {
/* ON_ENTER ON_LOOP ON_EXIT EVT_TIMER_G EVT_TIMER_Y EVT_TIMER_R EVT_NEXT EVT_GREEN EVT_YELLOW EVT_RED ELSE */