run loop until input is high

Hi,

I am looking for some advice on a simple LED program I am working on.

I have an english and french button with LEDS. I would like the LEDS to alternately flash (attract mode) until a user pushes one of the buttons. If the english button is pressed, I would like the english LED to stay solid for x amount of seconds. Then return to the "attract mode" loop.

Seems like a simple idea. I can get my lights to alternately flash, however the state doesn't change when I momentarily push the "english" button. If I hold down the english button, it will eventually switch to a solid light for 5 seconds. (as I've designated)

I'm guessing that it runs through the loop, then polls for digitalread state, doesn't find it's high, runs loop again etc. If I hold it down, after it finishes the loop it then polls my digitalread state to find it high, then runs the if statement.

Is there a way to run a loop, and start a new loop as soon as that input goes high?

Here is the code I am using.

Thanks very much!

Cheers,

// Lets get some LEDS to blink alternately

const int ELED = 12; // English LED Connected to pin 12
const int FLED = 13; // French LED Connected to pin 13
const int EBUTT = 7; // English Button Control to pin 6
const int FBUTT = 6; // French Button Control to pin 7

void setup ()

{
pinMode(ELED, OUTPUT); // This line sets our constant integer ELED as an output
pinMode(FLED, OUTPUT); // This line sets our constant integer FLED as an output
pinMode(EBUTT, INPUT); // This line designates EBUTT as an input
pinMode(FBUTT, INPUT); // This line designates FBUTT as an input

}

void loop()

{

EVAL = digitalRead(EBUTT); // read English input value and store it
FVAL = digitalRead(FBUTT); // read French input value and store it

digitalWrite(ELED, HIGH); // Turns ELED on High
delay(1000); // Wait for one second
digitalWrite(ELED, LOW);
delay(1000);
digitalWrite(FLED, HIGH);
delay(1000);
digitalWrite(FLED, LOW);
delay(1000);

if (EVAL == HIGH) {
delay(10);
digitalWrite(ELED, HIGH); // Turn English LED solid and French to low
delay (5000);
digitalWrite(FLED, LOW);
delay(5000); // Keep solid for 5 seconds.

}

}

Study the Blink Without Delay example.

If you want to be able to respond to a button on-demand, you'll need to get rid of your delays().

Hey,

Thanks for your input and insight!

Cheers