State machine

http://gameprogrammingpatterns.com/state.html

https://www.norwegiancreations.com/2017/03/state-machines-and-arduino-implementation/