I want to break out of my current loop when one of the buttons is pressed and jump to a different function.
Are there any tutorials or sample code that will get me up and running?
Probably. But, if you move from the abstract to the specific (exactly what do you want to do, for how long, when what button is pressed), the answers you get will be better.
Basically I have 9 functions each doing different LED patterns on my Arduino.
I also have a function that reads my IR sensor and returns back if button as been pressed (1 through 9).
What I want to do is to break out of the current LED animation and switch to which ever the user has selected, I don't want to wait for the current animation to finish before checking to see if there has been an IR code received as some of the animations loop forever.
Basically I have 9 functions each doing different LED patterns on my Arduino.
I also have a function that reads my IR sensor and returns back if button as been pressed (1 through 9).
That was hard to see from your code.
What I want to do is to break out of the current LED animation and switch to which ever the user has selected, I don't want to wait for the current animation to finish before checking to see if there has been an IR code received as some of the animations loop forever.
Then, it is time to re-write those animations.
You really want to implement a statement machine, and get rid of every single delay in your code.
Look at the blink with delay example. While there may appear to be a lot of states to deal with, you can't make a responsive application using delay.
As a stop-gap, you need to call the IR reader function more often (in each do-something function) and return from that function if a button was pressed.
Phil, a little bit of programming approach: Program = Code + Data.
A state machine is one where data drives the code. What you put in loop() is the guts of your code without a lot of the organizing structure that intro through intermediate computer courses would have you use. You change the state value to change the run time behavior, that's how a small bit of data replaces a lot of PITA indent levels and code. Result is you only need to write the "tops of the indents" with minimal support structure, usually a switch/case statement which makes it relatively easy to add or delete functionality.
Loop() is your friend. It lets you not do every thing every time through. That lets you not have to execute a check for every step or write cascading breaks, etc.
The computer I'm sitting at right now does that all the time. It turns sensible things I type into nonsense. Haven't worked out how to turn it off either.