Finite State Machines in C

If the flow of the program (not the program logic) is controlled by input events, this programming model is called "Event Driven Programming". That means the Event Driven programs are triggered by an event in one system and trigger a predefined corresponding event in another. Events can really be anything that happens in an embedded system. An input signal, a messages from other devices, a data from database — all these are events and that can trigger an event in another system.

State machines are perhaps the most effective method for developing event-drive code for embedded systems.