Arduino Finite State Machine