Hi,
I have a problem with using single click and doubleclick on the same button. When I do a doubleclick first it makes first a single click (which is technically quite obvious). So when I want to trigger a doubleclick function after the first click it triggers single click function and after second click triggers doubleclick function. How to stop triggering single click when I want to trigger doubleclick? I tried delaing single click function but "delay(n)" freezes Arduino and it doesn't recognize second click.
For sure there is some easy workaround.
Thanks for any help.
You need to check out the BlinkWithoutDelay() example to see how to track elapsed time without using delay(). When you detect the single button click, you record the time. After a certain amount of time, if the button has been clicked you do your double click routine. If it has not, you do your single click routine.
I would use a millisecond timer NOT DELAY and count the number of state changes in a short period, do remember to to allow for debounce.
Look for State change, Blink without delay and Several things at one time, try each one and then see how the concepts can be used to create the code you need.
Once you get some code started post it here (using code tags) and people can help tidy it up.
Hi once again,
I'm having really hard time implementing your advice.
The problem is in my code everything is happening in functions outside loop. I based my code on EasyButton library which inside loop only checks buttons states and than it triggers a function from outside of the loop.
As I understand I cannot use millisecond timer outside the loop, because the function is going to be read just once and the condition currentmillis - buttonclickmillis >= buttondelay never will be fulfilled.
Is there any way to implement millisecond timer outside the loop function?
Well, I have to admit... I gave up and finally used a millis delay library... But it works
I need to practice my understanding of millis timers and "delays" because it's very useful.
Thanks for your help.