Problem about background actions

Hello everyone,

I'm quite new to the "arduino-world", so excuse me if this is a really stupid question or something.

I have been trying to make a circuit that closes a relay every couple of seconds, to make my camera take pictures over a period of time and make a time lapse. I've stumbled on a small problem: I connected a button to scroll through different presets, but I can't press the button every time I want. I think I know where the problem is but I don't know how to solve it. I found that out by making the arduino send the message "OK" when the button is pushed. I guess it's because I ask what the state of the button is in the beginning of the loop, but after that moment has passed, I have to wait until it loops again to be able to give the command again.
I hope there's someone who wants to help me, and can give me an easy explanation, because like I said, I'm pretty new. I got my arduino starter kit as a newyear's present and haven't got that much programming experience.
Thanks anyway.

const int ledPin = 8;
const int cyclePin = 2;
const int bounceDelay = 50;
int lastCycle = LOW;
int mode = 1;
long lastCycleDebounce;
int cycleReading;

void setup()
{
	Serial.begin(9600);
	pinMode(ledPin, OUTPUT);
	pinMode(cyclePin, INPUT);
}

void loop()
{
	if(digitalRead(cyclePin) == HIGH)
	{	lastCycleDebounce = millis();
	}
	
	if((millis() - lastCycleDebounce) > bounceDelay)
	{	if(mode < 5)
		{	mode ++ ; }
		else
		{	mode = 1 ; }
		Serial.println("OK");
	}
	
	
	if(mode == 1)
	{
		digitalWrite(ledPin, LOW);
		delay(500);
		digitalWrite(ledPin, HIGH);
		delay(500);
	}
	if(mode==2)
	{
		digitalWrite(ledPin, LOW);
		delay(1000);
		digitalWrite(ledPin, HIGH);
		delay(500);
	}
	if(mode==3)
	{
		digitalWrite(ledPin, LOW);
		delay(2000);
		digitalWrite(ledPin, HIGH);
		delay(500);
	}
	if(mode==4)
	{
		digitalWrite(ledPin, LOW);
		delay(3000);
		digitalWrite(ledPin, HIGH);
		delay(500);
	}
	if(mode==5)
	{
		digitalWrite(ledPin, LOW);
		delay(4000);
		digitalWrite(ledPin, HIGH);
		delay(500);
	}
}

I think I know where the problem is but I don't know how to solve it.

If you think the problem is here:

		delay(500);

you are absolutely right. If you think it is somewhere else, you are wrong.

So, where do you think it is?

Look at how to manage timing using millis() in the demo several things at a time.

...R

I did think my mistake was there.
@Robin2, I'll check it out, thanks.