Finite state machine on arduino with Serial Interrupts

That was done; not quite tailored to OP's needs but sufficient (in my opinion) to get started.

And the obvious tutorial is Serial Input Basics - updated.