I've been playing around with my Arduino kit and finally pieced together the code to create a delayed "on" after 5 seconds when the switch I have is held (it's the cheap one that comes with the kit). It works perfectly for the first press (and hold) of the switch, holds a green led high and a red led low for 5 seconds, then flips them. However, I have to hit the Uno's reset button to get the sequence to run again, or else, when I hold the switch down subsequent times the red led that is meant to delay immediately comes on.
I'm using millis instead of the delay function (or command, whatever you call it) and I'm needing to know how to tidy up the end of the code so that once the switch is released, I can press it again and start the original, delayed sequence again. I've seen the examples for the "if" function where "currentTime - previousTime...blah blah blah," but I don't need the code to create a blink or oscillation. I would like the circuit to eventually turn off at a predetermined time interval (20-30 minutes) if it is not interrupted by another switch press. I'm using millis because I do want to add other operations that need to run no matter what, so the delay function won't help.
Any help would be greatly appreciated, I think I am just missing something simple to add on the end but my Google-fu didn't turn up anything.
I'm using millis instead of the delay function (or command, whatever you call it) and I'm needing to know how to tidy up the end of the code so that once the switch is released, I can press it again and start the original, delayed sequence again. I've seen the examples for the "if" function where "currentTime - previousTime...blah blah blah," but I don't need the code to create a blink or oscillation. I would like the circuit to eventually turn off at a predetermined time interval (20-30 minutes) if it is not interrupted by another switch press. I'm using millis because I do want to add other operations that need to run no matter what, so the delay function won't help.
Any help would be greatly appreciated, I think I am just missing something simple to add on the end but my Google-fu didn't turn up anything.