EmbDev.net

Forum: µC & Digital Electronics Arduino double click button


Author: Maurice Wirth (iciwi)
Posted on:

Rate this post
0 useful
not useful
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.

Author: Toto mit Harry (Guest)
Posted on:

Rate this post
0 useful
not useful
Int Clickcount
Int mydoubleclicktimeout()
Int mylastclick
Mypinstatus //debounced
While()

If(mypinstatus&&clickount==0)
Mylastclick=millis()
Clickcount++
Mypinstatus=0
Else if(mypinstatus&&clickount==1&&millis()<=mylastclick+mydoubkeclicktimeout)
//Doubleclickaction
Clickcount=0
Else if(mypinstatus&&clickount==1&&millis()>=mylastclick+mydoubleclicktimeout)
Mylastclick=millis();

Author: Quax (Guest)
Posted on:

Rate this post
0 useful
not useful
You can use this library: https://github.com/TOLDOTECHNIK/TTBOUNCE
It has a double click event and also debounces your hardware button.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.