Example finite state machine - Princeton University