Run Void *** when button is pressed

Arrch:
In order to have a responsive momentary switch that changes states you need to have those "states" to run non-blocking code. That typically means no non-trivial delays(), and very limited usage of for/while loops. In the flashSlow() and flashFast() code that you posted, that would mean you would need to redo those functions to not use delays. The blink without delay example shows you how to do just that. Another observation is that in the original code you posted, you run pattern() only during the rising edge once, and and pong all the other times. Assuming pattern() and pong() are non-blocking, you would be better off setting a state variable when you detect the transition. Then outside of the if statements, have your code check the state and run either pattern() or pong() based on its value.

Thank you for your understanding Arrch, I was on the verge of binning all my Arduino kit, giving up and buying my mum a kindle!
I'm not a scrounger, I am reading everything I can but I'm really struggling with the code concept.
Whilst your comments above sort of make sense to me, I haven't a clue where to begin to implement them. Straight over my head mate :slight_smile:

I posted up the simple LED flash code to better understand what I'm doing wrong in my main project code.

Would you kindly re-write the code for the example LED flash code so that it would switch back and forth when a button is pressed? then I'll have some code to study so as to make the changes to my main code.

Thanks Arrch,