Start and stop a sequence of LEDs with the same button.

Good afternoon,

I would like to know in what way it is possible to stop and / or restart what has been written in a loop, for example I have a circuit in which there are approx 6 leds which light interspersed for a certain time, now I want that sequence to stop pressing a button and remain lit in the state in which they are and then to re-press the sequence continue where it left off.

This question belongs in the "Programming Questions" section of the forum, not the "Sensors" section.

Suggest you ask a Moderator to move it there (see the "Report to Moderator" link below your post?)

You should also peruse "Useful links" 2nd from the top in the "Programming Questions" section, especially the "General design" topic.

After you study those, I predict that the solution to your problem will become clear.

ricmome:
Good afternoon,

I would like to know in what way it is possible to stop and / or restart what has been written in a loop, for example I have a circuit in which there are approx 6 leds which light interspersed for a certain time, now I want that sequence to stop pressing a button and remain lit in the state in which they are and then to re-press the sequence continue where it left off.

I'm guessing that your sequence is done with delay(). That will tend to make a button unresponsive because while the delay() is looking at the time, waiting for the delay to complete, you sketch can't be doing anything else (like checking buttons). Ideally you would re-write you sequence so it is done without using the delay() function. That would allow you to check the button and toggle between 'running' and 'stopped' states when the button is pressed.

The cheap and dirty way is to write your own function to call in place of delay(). Your function would still sit in a loop, looking for the 'delay' to expire, but inside that loop it would also be looking for button presses. If the button is pressed, it would switch to just waiting for the button to be pressed again. Your sequence (your entire sketch) would then do nothing until the button is pressed again.

Of course I'm only guessing because you did not show your sketch.