Your code has a lot of for-loops and function-calls delay()
For-loops and while-loops are blocking
and delay() is blocking.
the function delay() should have better the name
freeze_microcontroller_COMPLETELY_stop_ALL_code_execution_until_freezing_time_is_over()
This means your whole code has to be NON -blocking
It will take you some time and some thinking it over to understand it.
Here is a small tutorial that shows the principle how to write non-blocking code
Hi Everybody,
from time to time I enjoy writing tutorials in my kind and style.
My intention is to make it easy to understand. Though I'm aware:
of the fact that one way of explaining things is not the best way for everybody.
that the best experts about easyness-to-understand are: beginners .
I want to encourage especially beginners to ask whatever question comes to their mind.
I will use these questions as suggestion to improve the tutorial to become even more easy to understand.
The u…