I'm making a code so I can drive my little car via Bluetooth. I want 1 button to activate a loop and the other button to stop that loop(I'm talking about blinking lights or a little song with a zoomer). I tried to do so via a simple loop but I have to fill the "Times" in, this way I can't stop the loop while the amount isn't done yet...
Sorry if my sentences aren't that great I'm from Belgium so
Note how each function runs very briefly and returns to loop() so the next one can be called. None of the functions tries to complete a task in one call. And there may be dozens of calls to a function before it is actually time for it to do anything.
Use the buttons to change the value of a variable.
Use the value of the variable to determine which parts of the program are active.