Most of simple microcontroller applications can be modelled through finite-state machine (FSM). This is a simple and powerful approach. Now the question is “how should I implement it?”. Using an object oriented language like C++ usually lead to the implementation of the state pattern. I had to implement it using C for an MSP430 microcontroller.