An embedded system is a controller build in a larger device or installation in order to perform some automated or controlled tasks. Embedded systems use microcontrollers like on a MEGA2650 board. The MEGA2560 has a single chip with the possibility to connect with pheripherals to communicate with the outer world like analogue and digital converters. Programming the Arduino board with the theory of the FSM, is a good base for building controls.
The Arduino is programmed[1] by a subset of C/C++ structure text language. Knowledge of C/C++ is required to understand the following chapters where declarations and functions are described. I decided not writing a special FSM library, simply because it don’t add any functionality, it only shortens the code of the sketch. The AFSM functional code of the the Finitie State machine and the I/O configuration is put in seperate *.h files; UserFiniteStateMachine.h and UserConfiguration.h

[1] Wikipedia: “Structured text is one of the five languages supported by the IEC 61131-3 standard, designed for programmable logic controllers and embedded systems. It is a high level language that is block structured and syntactically resembles Pascal, on which it is based. All of the languages share IEC61131 Common Elements“.