Download this file
#include "listener.h"

bool Listener::canRun(uint32_t now) {
  return Serial.available() > 0;
}

void Listener::run(uint32_t now) {
  char c = Serial.read();
  if (c >= '0' && c <= '9') {
    value = value * 10 + (c - '0');
  }
  else if (c == '\n' || c == '\r') {
    Serial.println(value, DEC);
    state_machine->input(value);
    value = 0;
  }
  else {
    // do something?
  } 
}

// vim:ft=arduino