Hey there, I want to add a double click function in my code. But how can I do this? And is ther a possiblity to distinguish between a normal click and a double click? I'm looking forward to your replies. Best regards Maurice W.
1 | Int Clickcount |
2 | Int mydoubleclicktimeout() |
3 | Int mylastclick |
4 | Mypinstatus //debounced |
5 | While() |
6 | |
7 | If(mypinstatus&&clickount==0) |
8 | Mylastclick=millis() |
9 | Clickcount++ |
10 | Mypinstatus=0 |
11 | Else if(mypinstatus&&clickount==1&&millis()<=mylastclick+mydoubkeclicktimeout) |
12 | //Doubleclickaction
|
13 | Clickcount=0 |
14 | Else if(mypinstatus&&clickount==1&&millis()>=mylastclick+mydoubleclicktimeout) |
15 | Mylastclick=millis(); |
You can use this library: https://github.com/TOLDOTECHNIK/TTBOUNCE It has a double click event and also debounces your hardware button.
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.