Hey Arduino Family!
I got y first arduino this week and i havent put it down since it arrived, I'm totally hooked.
I'm really a complete novice with coding but I am slowly starting to take it on board and can somewhat understand what the lines of code are doing (even thought I never thought that I would! lol)
So I am making this kind ambient lamp from RGB leds
I have these two pieces of code that work just fine on their own.
One cycles through colours nicely in a rainbow kinda effect and the other allows the colours to be set using 3 pots that are controlling the PWM signal.
What I would like to do is connect a momentary push button switch that takes it out of the rainbow cycle code and places it into 'manual' mode handing over control to the user.
I was thinking that this would perhaps look something like this:
The main loop for the rainbow effect is running, at the top of the loop check to see if the button is pressed and if it is then exit the loop and continue down the program, at which point it would hit the next loop which is the manual control section, perhaps in this loop it could look for the button being pressed again and switch back to the first loop putting it back into rainbow mode again'
The two sketches I have been using are pasted below.
any help that will start pointing me in the right direction would be really appreciated. thanks guys. 
RGB Rainbow
const int redPin = 11;
const int greenPin = 10;
const int bluePin = 9;
void setup() {
// Start off with the LED off.
setColourRgb(0,0,0);
}
void loop() {
unsigned int rgbColour[3];
// Start off with red.
rgbColour[0] = 255;
rgbColour[1] = 0;
rgbColour[2] = 0;
// Choose the colours to increment and decrement.
for (int decColour = 0; decColour < 3; decColour += 1) {
int incColour = decColour == 2 ? 0 : decColour + 1;
// cross-fade the two colours.
for(int i = 0; i < 255; i += 1) {
rgbColour[decColour] -= 1;
rgbColour[incColour] += 1;
setColourRgb(rgbColour[0], rgbColour[1], rgbColour[2]);
delay(5);
}
}
}
void setColourRgb(unsigned int red, unsigned int green, unsigned int blue) {
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
=================================================
RGB Color Chooser
// Init the Pins used for PWM
const int redPin = 9;
const int greenPin = 10;
const int bluePin = 11;
// Init the Pins used for 10K pots
const int redPotPin = 0;
const int greenPotPin = 1;
const int bluePotPin = 2;
// Init our Vars
int currentColorValueRed;
int currentColorValueGreen;
int currentColorValueBlue;
void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop()
{
// Read the voltage on each analog pin then scale down to 0-255 and inverting the value for common anode
currentColorValueRed = (255 - map( analogRead(redPotPin), 0, 1024, 0, 255 ) );
currentColorValueBlue = (255 - map( analogRead(bluePotPin), 0, 1024, 0, 255 ) );
currentColorValueGreen = (255 - map( analogRead(greenPotPin), 0, 1024, 0, 255 ) );
// Write the color to each pin using PWM and the value gathered above
analogWrite(redPin, currentColorValueRed);
analogWrite(bluePin, currentColorValueBlue);
analogWrite(greenPin, currentColorValueGreen);
}