Here is my personal variant that reduces the number of lines of code to write a timer
including an explanation how it works based on an everyday example
non-blocking timing. Execute code only from time to time.
There are a lot of different ways to learn programming. This thread wants to add another approach that is different to the yet existing ones.
UPDATE 06.01.2023
if you are mainly interested in applying non-blocking timing you can do a quick read of this
short tutorial / demonstration
If you are intersted in understanding the details how it works go on reading here.
I use an everyday analogon in this post to explain the basic principle …