Finite state machine on arduino with Serial Interrupts

Not tailored to your needs but below should give you the idea

  char cmd = 0;
  if (Serial.available() > 0) {
    cmd = Serial.read();
  }

  if (cmd == 'S') {
    Serial.println(state);
  }

A complex library for a simple problem.

1 Like