Just wanted to share this info about understanding State Machines better.
To the uninitiated, the words ‘State machine’ sounds like something scarily big and complex. They aren’t (necessarily) and can be quite useful. In fact, state machines are no physical machines but a model of processes. They link the states a system can be in with allowed transitions. For example, a media player when stopped can change to play or open another file. While playing, it can go to pause, stop, reverse, fast forward and so on.
A state machine creates a map of all states and how they are connected. It is an abstract tool that offers a graphical approach to organizing your code before actually programming.
In his video [Chris Guichet] uses a state machine to debounce a switch for a beginner friendly introduction of the concept. He then shows how to turn the hand-drawn map to actual code, including a section on debugging state machines.
State machines are one of the tools that veterans wield easily but often have a hard time to explain to youngsters. This video solves this.