Newbee Delayed switch output

I would like to monitor an input (from switch) and then if the input state remains high for a period of say 5 minutes generate a high output. Can anyone point me in the right direction.
Thank you

Record the time when the input goes from low to high.
When 5 * 60 * 1000UL milliseconds have elapsed, trigger your output.

Use the millis() function to get the time when the switch BECOMES high. See the state change detection example to determine when the switch becomes high. Also, set a flag.

When the flag is true, see if the switch is still high and what time it is now. If the switch is no longer high, clear the flag and the start time. If the switch is still high and enough time has passed, throw a fit. I mean, set the other pin high.

Thanks for the replies. I need the input to be consistently high during the period in order to trigger the output high, not just at the beginning and end of the period. Will this change things ?

I would like to monitor an input (from switch) and then if the input state remains high for a period of say 5 minutes generate a high output. Can anyone point me in the right direction.
Thank you

look at the IDE BlinkWithoutDelay Example

I need the input to be consistently high during the period in order to trigger the output high, not just at the beginning and end of the period. Will this change things ?

No.

Cool. Thanks.
Is there a best way to get around the problem people talk about with delays after 49 days ?

Freddy99:
Cool. Thanks.
Is there a best way to get around the problem people talk about with delays after 49 days ?

If you need only 1-second precision, store your times as seconds not milliseconds. Gets you about 68 years with signed 32-bit ints, twice as long unsigned. If you want millisecond precision for a stupid long time, use 64-bit numbers (long long):

unsigned long long now=0;
unsigned int lastms=0

void setup()
{
  lastms=millis();
  now=lastms;
}

void poll()
{
  unsigned int now32=millis();
  now+=now32-lastms;
  lastms=now32;

  // do other stuff...
}

It doesn't matter that millis() will overflow because you're always adding the difference of two subsequent calls to millis(), which (as long as your loop function doesn't take weeks!) will always be a small positive number despite the overflows. Of course, manipulating 64-bit ints in an AVR isn't real cheap, but it's much faster than floats!