Hold input for set time

OK I am trying to make write a program that will watch 1 digital input to see if it goes HIGH 2 times in 5 seconds, if it does then it will send 2 outputs one HIGH and one LOW. I can't seem to get my head wrapped around the int Reading command and maybe that's not the right one to use for this idea........CAN SOMEONE PLEASE HELP! I am working on a simple circuit with 2 LED's if the button is push twice in 5 seconds both LED's come on. Thank You for your time jxs058959.

Start with figuring out what steps YOU would take to perform the task manually.

  1. Take an empty post-it note
  2. Wait for the button to be pushed.
  3. if the post-it note is empty:
    go to Step 5
  4. if the post-it note is not empty:
    If the time on the post-it note is less than five seconds before now:
    Set the lights!
    erase the post-it note
  5. write down the time
  6. wait for the button to be released
  7. go back to Step 2

Make a counter.

Make it = 0
Using millis, make a 5 second loop.
If the button is pressed, inside the loop, increment a counter.
At end of the 5 second loop, test the counter.
if the counter == 2 then turn on LEDs.

steinie44:
Make a counter.

Make it = 0
Using millis, make a 5 second loop.
If the button is pressed, inside the loop, increment a counter.
At end of the 5 second loop, test the counter.
if the counter == 2 then turn on LEDs.

or just timestamp the last change to HIGH.

each time you test for a change to HIGH, compare it against the last time…

pseudo post it note:

if (signal == HIGH)
  {
    thisTime = millis()
    if (thisTime - lastTime < theDesiredInterval) doSomething();
    lastTime = thisTime;
  }