Mealy machine
In this machine, the output produced by the state machine depends on the input events fed to the state machine AND present active state of the same machine.
The Output is not produced inside the state.
- Output is represented along with each input separated by
/
- An "Output" is also called "Action".
- In the mealy model, the "Output" is also called "Input action".
Light switch state machine
In this example, the light switch has two buttons (ON/OFF) and 4 states (OFF, DIM, Medium bright, Bright) and depending on which button is pressed and the previous state the next state will change.
Only one button (ON) is necessary to transition from the initial state to the final state (Bright).
The OFF button can turn off the lamp from any state.
State transition table - Light control Mealy machine
The Mealy machine can also be represented in table form. Here, the present state can be used as a starting point to analyze what will happen when an input is introduced, both the next state and the output can be known from there.
- When the state machine is in "OFF" state and if:
- Input event "ON" is received, then the state machine produces the output "Dim the light" and makes a transition to "Dim" state.
- Input event "OFF" is received, the event is ignored.