Pause a function

Hi

I'm making a simple light game on Arduino Uno at the minute. I want to be able to have my game to run a light pattern normally using a for loop, but when a button is pressed, I want it to pause the for loop, do something else, then go back to the for loop. At the minute I've managed to get it to do what I want by using an interrupt with delays, but I've read in several places that doing this should be avoided. Any suggestions for what might be a better way of doing this?

Thanks

At the minute I've managed to get it to do what I want by using an interrupt with delays

Try a state-machine, dump the delays and the interrupts.

Edit: DO NOT CROSS-POST - IT WASTES TIME

Duplicate deleted.

Please post answers here

Thread locked.