-->
Page 1 of 2

Button, long press and short press

PostPosted: Tue Jul 16, 2019 3:12 am
by panoss
I want to connect a push button switch to some pin on an ESP8266.
I want to be able to detect (and distinguish) long press and short press.
I read about Arduino libraries that make this really easy, also offering debounce.

Is there something for ESP8266?
Or is there some Arduino library that can be used with ESP8266?

Also, I 'm thinking of connecting the button this way:
ESP8266_button.png


Is it ok? Can I do it with less components?

Re: Button, long press and short press

PostPosted: Tue Jul 16, 2019 2:48 pm
by schufti
you could define the input with pullup and save the resistor ...

Re: Button, long press and short press

PostPosted: Wed Jul 17, 2019 6:08 am
by panoss
You mean in the code:
Code: Select allpinMode(3,INPUT_PULLUP);


And the hardware:
ESP8266_button_b.png


?

Re: Button, long press and short press

PostPosted: Wed Jul 17, 2019 8:45 am
by schufti
yepp

library: OneButton