Finite State Machine Code Example, The code is quite simple.