Use the state change detection method to sense when the button becomes pressed and set a flag. Then if the flag is set run the loop. If the button becomes pressed again, clear the flag to stop the loop.
Use the state change detection method to sense when the button becomes pressed and set a flag. Then if the flag is set run the loop. If the button becomes pressed again, clear the flag to stop the loop.