Topic: reading pushbutton. only if HIGH for 5 sec or more, start next routine (Read 2551 times)previous topic - next topic

lightblue

Hi, with the first part of this softwareprogram I use a pushbutton (will later on be replaced by a PIRsensor) as trigger to start the main routine called Rumple. The goal is that: if button is not pushed, nothing happens + if button is pushed quickly, nothing happens + if button is pushed several times quickly, nothing happens + if button is pushed for 5sec or longer, the main routine starts. By adding the command serial.println I could find out that all possibilities work, except when button is pushed for 5sec or longer. It then seems to recognize the long push as fragmented, thus similar to a few short pushes. I tried 3 different ways of programming to get the long push recognised as such, even combining the bouncing command into the pulseIn software (not added as not it was not working either); none was working. As I presume the problem will remain when later on I replace the pushbutton with a PIRsensor, I really would like to find a solution. extra info: working with an arduino micro on a breadboard.thanks in advance !

I did something similar to this once. I had a routine that would check to see if a button is being held. If it was, a counter would decrement during each cycle of the loop. Once the counter reached zero, the button behavior was different.

I wanted to do what you see with a lot of clocks. When you push a button and hold it, it counts slowly at first, then very quickly after the button has been held for a few seconds. Worked great.