Its worth learning about state machines and state-transition diagrams, as they facilitate coding complex
behaviours - state transition diagrams are intuitive, and they map to code free from delays straightforwardly.
They also make it easy to have several bits of behaviour running in parallel independently.