Understand a simple pattern recognition state machine expressed as an Arduino program using several idiomatic C/C++ program structures.
This is a very simple single-input binary pattern recognition system. However, even this state machine could be used to recognize synchronous inputs from a communications channel.
This graph represents the set of discrete states modelled by the system. States are illustrated as ovals and transitions as arrows. Each state can have an associated output, in this case the LED. Transitions between states are defined by condition rules. Each transition has a one-second duration to make it feasible to manually manipulate the switch input with the right timed sequence to walk through the graph.
This same recognition exercise could be extended to any binary input: optical switches, wall contact switches. It could also be extended to any possible sampling rate, including cycling loop() as fast as possible.
The transition properties could be extended to include other predicates: comparisons on elapsed time to prevent exiting a state before time has elapsed, more elaborate mappings of linear inputs to transition state.
You may now recognize that the switch debouncing code introduced much earlier is a specific case of a finite-state machine implementing time-based hysteresis.