deltaTime and loop() in arduino

you have been guided in the trap of linear thinking by using the example-codes provided by the arduino-IDE that use delay().

As long as you try to stay inside linear thinking it will be impossible to think about how to solve this task.

For solving this task of only using void loop() for everything you have to get rid of

  1. the linear thinking that delay() is
  2. learning about conditional code-execution based on the switch-case-break-statement (state-machine)
  3. learning to think circular which is the complete opposite of linear

Using void loop() as the only loop

But this will be not enough
for the timing you will need non-blocking timing
Example-code for timing based on millis() easier to understand through the use of example-numbers / avoiding delay()

If you don't want to get lost in a big mess of many many if-conditions
you will have to learn how state-machines work

best regards Stefan