In this article I am going to walk through the steps of designing a state machine. There are various different ways to design and develop state machines, in this article I am going to use the way I design them. We are going to design a state machine that will simulate the electronic controls for an elevator. The elevator has 2 buttons, up and down, and the elevator runs between 4 floors.

The first step in designing the state machine is to first list all of the states you think will be needed to design the state machine. For this case we will create a state for each floor:

1) First_Floor / Ground_Floor

2) Second_Floor

3) Third_Floor

4) Fourth_Floor

Now that we have all of the states defined, we need to place the states and determine how our design will transition through the different states. We know that our design can only transition using the 2 button inputs, up and down. Every time the user presses the up button the state machine increases by a floor. Every time the user presses the down button the state machine goes down a floor. Once the user reaches the highest floor if they press the up button they will stay on the current floor. The completed state diagram is shown below.