Figure 2: State diagram modeled using Moore Implementation with Stateflow.