It might be interesting for you to evaluate the concept of a state machine; see here for a simple example
https://forum.arduino.cc/t/help-with-code-if-possible/1201603/9
It might be interesting for you to evaluate the concept of a state machine; see here for a simple example
https://forum.arduino.cc/t/help-with-code-if-possible/1201603/9