Adam Fraser-Kruck

Visualize Your State Machines
Status: Available NowLet's dive into state machines by building an embedded security system!
Important Info
You should probably view my presentation as two parts:
- First half = introduction
- Second half = advanced
The first half provides a nice intro to visualizing state machines and using StateSmith with PlantUML. If all you want is some introductory info, it's OK to stop here :)
The second half starts to get more advanced and provides exclusive content to Embedded Online Conference attendees. It goes above and beyond what is already available in free StateSmith tutorials. I would highly recommend downloading the example project and following along (pausing when needed).
Presentation Description
State machines are an incredibly helpful pattern for embedded systems, but hand-coded state machines can be difficult to understand and maintain, especially as designs become more complex with additional states and transitions.
To make our lives easier, we are going to use StateSmith to visually model our state machines in PlantUML.
StateSmith is a cross-platform, free/open source tool for generating state machines in multiple programming languages (C, C++, C#, Java, Python, JavaScript, TypeScript). The generated code is human-readable, has zero dependencies, and is suitable for use with tiny bare-metal microcontrollers, video games, apps, web, computers, and more. It avoids dynamic memory allocations for those focused on safety or performance. Each state machine instance only requires a single byte of RAM.
We'll start by creating a simple button state machine that performs debouncing and long press detection. Then we will connect those button state machines to our Control and Display state machines.
Every step of the way, we will simulate our design using Wokwi (an online electronics simulator) so that you can easily follow along without any physical hardware.
Helpful Links
I'm happy to answer questions here, on GitHub or Discord.
Got any interesting state machine stories to share? I'm always interested :)