using a button to switch modes

So as I am sure it obvious from my question I am very new to all this. I have several sketches that I would like to combine into one sketch and have the ability to cycle through them via a button, however I cannot find any information on how to achieve this. If you guys can clue me in here that would be great here is a video of my ring running through it's cycles (just a demo I threw together)

http://www.youtube.com/watch?v=_v2QKePwx40

conceptually:

void loop(){
button read code, if  button is pressed  advance 'mode' by 1 count, reset to 0 when hit upper limit

switch (mode){
case 1:
program 1;
break;

case 2:
program 2;
break;

case 'n':
final program
break;
} // end switch
} //end void

Got a pic of the hardware? Looks kinda neat.

A minor detail:

while(no button is pressed) { program 1 }

This way you still get your loop and can escape to "menu" at at button press.

If you have spare pins for an LCD you can construct a menu system I designed:

http://arduino.cc/forum/index.php/topic,62021.0.html

Those are angel eyes, but color ones? Here in Portugal you would get a nice fine/ticket with those..

What if you are just showing off in the parking lot with your friends?

it is in fact an angel eye, I built it from 3/8" acrylic rod it has RGB LED’s in either end hence the color ability (the video camera I used is really lousy it looks much better in person) in the US if I were to ride with all the pretty colors I would make it a block before I got a ticket, if I rode with the red and blue I would likely be arrested. Having said that these are RGB LED’s which means nearly any color is possible, including white which is perfectly legal to ride with. I also will use them for hazard flashers (I will have rings in all my turn signals as well) flashing amber and white. The colors can and will be used at bike shows. Here are some pictures of the ring (uninstalled, the ring is now installed inside my headlight housing I will be making a new video soon)

White

Blue and red

lit up with camera flash

installed in the bike

CrossRoads, please forgive me ignorance like I said I am a newb where your sketch says

“button read code, if button is pressed advance ‘mode’ by 1 count, reset to 0 when hit upper limit”

is the button read code the analog read for the switch?

No, it should be a digital read. Going to be high or low only. Where you said you had several sketches already, I figured you'd be able to follow the software references.

I meant digital read sorry about that chock it up to lack of sleep (I have a 3 month old baby) I guess my confusion is exactly where I insert my sketch into your sketch. Like I said I am very new to this trying to wrap my head around all this. The sketch I wrote I suspect is probably WAY more complicated than it needs to be, however with my limited knowledge it was what I had to work with. I tried posting the code but the forum has restricted post character count (yeah it's that long) so here is a very short snip of what I have written

int redPin = 9;
int greenPin = 10;
int bluePin = 11;
int bluerPin = 5;
int greenrPin = 6;
int redrPin = 3;
void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(3, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}

void loop() {
//fast red strobe

 digitalWrite(greenrPin, HIGH);
  digitalWrite(redrPin, LOW);
  digitalWrite(bluerPin, HIGH);
  digitalWrite(redPin, LOW);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, HIGH);
delay(50);

digitalWrite(greenrPin, HIGH);
  digitalWrite(redrPin, HIGH);
  digitalWrite(bluerPin, HIGH);
  digitalWrite(redPin, HIGH);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, HIGH);
delay(50);

digitalWrite(greenrPin, HIGH);
  digitalWrite(redrPin, LOW);
  digitalWrite(bluerPin, HIGH);
  digitalWrite(redPin, LOW);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, HIGH);
delay(50);

digitalWrite(greenrPin, HIGH);
  digitalWrite(redrPin, HIGH);
  digitalWrite(bluerPin, HIGH);
  digitalWrite(redPin, HIGH);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, HIGH);
delay(50);


  digitalWrite(greenrPin, HIGH);
  digitalWrite(redrPin, LOW);
  digitalWrite(bluerPin, HIGH);
  digitalWrite(redPin, LOW);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, HIGH);
delay(50);

digitalWrite(greenrPin, HIGH);
  digitalWrite(redrPin, LOW);
  digitalWrite(bluerPin, HIGH);
  digitalWrite(redPin, LOW);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, HIGH);
delay(50);

digitalWrite(greenrPin, HIGH);
  digitalWrite(redrPin, HIGH);
  digitalWrite(bluerPin, HIGH);
  digitalWrite(redPin, HIGH);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, HIGH);
delay(50);


//slow blue strobe

digitalWrite(greenrPin, HIGH);
  digitalWrite(redrPin, HIGH);
  digitalWrite(bluerPin, HIGH);
  digitalWrite(redPin, HIGH);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, HIGH);
delay(150);

digitalWrite(greenrPin, HIGH);
  digitalWrite(redrPin, HIGH);
  digitalWrite(bluerPin, LOW);
  digitalWrite(redPin, HIGH);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, LOW);
delay(150);

digitalWrite(greenrPin, HIGH);
  digitalWrite(redrPin, HIGH);
  digitalWrite(bluerPin, HIGH);
  digitalWrite(redPin, HIGH);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, HIGH);
delay(150);

digitalWrite(greenrPin, HIGH);
  digitalWrite(redrPin, HIGH);
  digitalWrite(bluerPin, LOW);
  digitalWrite(redPin, HIGH);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, LOW);
delay(150);

digitalWrite(greenrPin, HIGH);
  digitalWrite(redrPin, HIGH);
  digitalWrite(bluerPin, HIGH);
  digitalWrite(redPin, HIGH);
  digitalWrite(greenPin, HIGH);
  digitalWrite(bluePin, HIGH);
delay(150);

The sections that you call // fast red strobe

// fast blue strobe

would each go into the place where I had program1;

and then program2;

etc. Your other setup stuff would be the same.

Then add some code at the beginning of void loop() to read the button press and advance the counter by 1 when pressed.

Congrats on the baby by the way! I thought my son was going to kill me with 6 months of sleep deprivation when he was born 8)

So the issue I am having even with the sketch suggested is the sketch is so long and it is looping the arduino isn't recognizing the button until the end of the sketch, if your not right on top of it at the end of the sketch it will not advance. I would like to be able to push the button at any given time and have it advance to the next mode.

Hey, long time no hear.

Try this
case 1:
program 1;
break; <<<gets you back to the top of the loop

so add some more breaks in your sketch:

digitalWrite(greenrPin, HIGH);
digitalWrite(redrPin, HIGH);
digitalWrite(bluerPin, HIGH);
digitalWrite(redPin, HIGH);
digitalWrite(greenPin, HIGH);
digitalWrite(bluePin, HIGH);

button_state = digitalRead (button); // or however you call it
if (button_state == (HIGH or LOW, whatever you use){
sequence_choice = sequence choice 1;
if (sequence_choice == (end of the line){ sequence_choice = (start of the line)}
break; // should get you out of the loop
}
delay(150);

Make sense?

I would do this instead to give more cpu time to button checking per loop:

#define threshold 20
void loop()
{
 // do some stuff with leds
  long t0=millis();
  while(t-millis()<threshold)
  {
    if(digitalRead(button1)==HIGH)
    {
      //do something
      //break;
    {
  }
}

This way you are guaranteed to have 20 milliseconds on the button. What matters is how much time you spend checking buttons compared with how much time it takes to loop one iteration.