Push-button FSMĀ 

The LED-Button example we studied earlier has little practical use. In most case, we like the button to operate with a simple push. We do not wish to keep pressing the button to light up the LED. One of the typical ways a push-button is used is that when we press down the button, we see action. This action should be done only once. When we release the button, nothing should happen. Once we press it again, we should see action again. We can implement this functionality using a simple FSM we call push-button. In this FSM, there are two states: we call them Up and Down. The momentary status of the button can be Pressed (P) or not pressed (!P). Note that the momentary reading of the button is not the same as FSM state. For example, an FSM can be in the "Down" state when you read the input of the button, and you read "not pressed." This input takes the FSM from "Down" to "Up." The output of this FSM is always "no action" unless we are transitioning from the "Up" state to the "Down" state. This is the moment we are pushing down the button.