How to make a push button override a timer?

Hey guys, just to start off, I'm a complete noob with arduino. So sorry about my lack of knowledge about the code...

I have just purchased a seeedstudio relay shield. I took a look at the sample code for it, and I have written a simple sketch that counts for 8 hours, then flickers the lamp on and off 5 times.

I have a simple spst push button that I want to toggle the lamp on and off when I press it, acting as an override for the timer.

When the button is pushed and released, the lamp should turn on, and when it is pushed and released again, it would turn off. I need this to work anytime, just in case I need to turn my lamp on or off during the day when the lamp is supposed to be off.

Help would be greatly appriciated!

Squerl101: I have written a simple sketch that counts for 8 hours, then flickers the lamp on and off 5 times.

But you're not going to share it with us?

You probably need to get rid of the delay() calls in your code.

I'll be uploading it in a minute, as I am using my iPad now.

PLEASE BEAR WITH ME, I KNOW IT'S A MESS. I don't know much about the Arduino language just yet. Here is the code so far just to make the timer work. The digitalWrites make the lamp and the buzzer sound.

//Simply gives the pins some names...

int lampPin = 4;
int buzzerPin = 13;

//Setup Code...
void setup () {
  pinMode(lampPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
}

void loop () {
  digitalWrite(lampPin, LOW);
  delay(28800000);                       //Counts from 10 PM to 6 AM.
  digitalWrite(buzzerPin, HIGH);         //Starts flickering the lamp and making the buzzer sound to wake me up :)
  digitalWrite(lampPin, HIGH);
  delay(500);
  digitalWrite(buzzerPin, LOW);
  digitalWrite(lampPin, LOW);
  delay(500);
  digitalWrite(buzzerPin, HIGH);
  digitalWrite(lampPin, HIGH);
  delay(500);
  digitalWrite(buzzerPin, LOW);
  digitalWrite(lampPin, LOW);
  delay(500);
  digitalWrite(buzzerPin, HIGH);
  digitalWrite(lampPin, HIGH);
  delay(500);
  digitalWrite(buzzerPin, LOW);
  digitalWrite(lampPin, LOW);
  delay(500);
  digitalWrite(buzzerPin, HIGH);
  digitalWrite(lampPin, HIGH);
  delay(500);
  digitalWrite(buzzerPin, LOW);
  digitalWrite(lampPin, LOW);
  delay(500);
  digitalWrite(buzzerPin, HIGH);
  digitalWrite(lampPin, HIGH);
  delay(500);
  digitalWrite(buzzerPin, LOW);
  digitalWrite(lampPin, LOW);          //Stops the flickering.
  delay(57240000);                     //Counts until 9:50 PM
  digitalWrite(lampPin, HIGH);         //Turns the lamp on before I go to bed.
  delay(360000);                       //Counts until 10 PM
  digitalWrite(lampPin, LOW);          //Turns the lamp off, then begins counting until 6 AM again.
}

Looking at the code, how long will you need to hold the switch down before it is recognized? Anywhere between 500 and 57240000 milliseconds (that's 956 minutes or almost 16 hours). Hope your finger doesn't get tired.

For those intervals, the blink without delay example is certainly more relevant.

I just need to be able to, at any time, press the push button instantly, and have the lamp turn on. If i press it again, it will turn off.

So if you will, the button needs to act as an override for the timer, so that regardless of what state the lamp is supposed to be in, it will turn on or off.

Also, I just have the relay shield connected to the Arduino. Nothing else but the buzzer on pin 13. So as of now, If I need the lamp on sometime before 10 PM, there is no way to do it.

Squerl101: I just need to be able to, at any time, press the push button instantly, and have the lamp turn on. If i press it again, it will turn off.

So if you will, the button needs to act as an override for the timer, so that regardless of what state the lamp is supposed to be in, it will turn on or off.

Also, I just have the relay shield connected to the Arduino. Nothing else but the buzzer on pin 13. So as of now, If I need the lamp on sometime before 10 PM, there is no way to do it.

I know it may seem simple in concept to you, but the Arduino isn't as smart as you, so what you need to accomplish needs to be done on the Arduino's terms. The Blink Without Delay goes over how to utilize a "stopwatch" (millis) and variables to allow the Arduino to do things (like read a switch's state) between changing the state of outputs pins.

Alright, I'll take a look at some guides and see what I can do.