Skip to content

PRO TIP Block youtube.com at the DNS level — Pi-hole, NextDNS or your hosts file — but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

#35 State Machines Part-1: What is a state machine?

62.3K views on YouTube

This lesson starts a new segment about STATE MACHINES. The lesson starts with the biggest challenge of event-driven programming, which is preserving the context from one event to the next. You’ll see how the usual improvised context management leads to “spaghetti code”.

Next, you’ll see a different approach, in which you capture only the “relevant history” of the system and how this leads to the concepts of “State” and “State Machine”. You’ll also learn the basic elements of state diagrams, and you’ll see how to design a state machine diagram for the “Blinky-Button” example.

Finally, you’ll see how state machines complement the Active-Object design pattern, and you
go through the experience of coding a state machine in C.

——-
Resources:

Companion web page for this video course:
https://www.state-machine.com/quickstart

GitHub repository for projects for this video course:
https://github.com/QuantumLeaps/modern-embedded-programming-course

Freeware QM modeling tool download:
https://github.com/QuantumLeaps/qm/releases

Transcript of this lesson:
https://www.state-machine.com/course/lesson35.txt

Music credits:
The background music comes from:
https://www.bensound.com/royalty-free-music/track/straight