-->
Page 1 of 2

help with arduino OneButton lib <solved>

PostPosted: Wed Jul 29, 2015 1:07 am
by schufti
Hi,
I have the OneButton-lib running on an original arduino with no problem.
As I found no specific AVR related code, I thought it save to use on ESP8266, too.
But unfortunately it isn't really useable, when you press a key it randomly detects a mix of one or more single and double clicks.
I allready changed OneButtop.cpp
Code: Select all  pinMode(pin, INPUT);      // sets the MenuPin as input
....
    digitalWrite(pin, HIGH);   // turn on pullUp resistor

to
Code: Select all  pinMode(pin, INPUT_PULLUP);      // sets the MenuPin as input w pullup

and disabled WiFi (WiFi.mode(WIFI_OFF)) to see if some "internal" things interfere with the OneButton timing but to no avail.

Can someone "in the know" have a look if I am missing something obvious?
Maybe reccomend a known working lib with similar functionality?

thanx a lot,
schufti

Re: help with arduino OneButton lib

PostPosted: Wed Jul 29, 2015 4:23 am
by rvtk
Which version of the ESP8266 Arduino IDE are you using? Try upgrading to the most recent version.

Recently the accuracy/behavior of millis() changed (which is used extensively by the OneButton lib), so maybe now it works. A similar issue was encountered in an topic about 433mhz senders/receivers, see viewtopic.php?f=13&t=2507.

Re: help with arduino OneButton lib

PostPosted: Wed Jul 29, 2015 7:26 am
by andrew melvin
I was interested in this lib, so downloaded it and gave it a shot.

Using one of the examples, I removed the wait for serial line, changed the pin from A1 to 0, and uploaded it to my nodemcu devboard.

Worked first time, detects all three types easily.
I am using the latest staging version of the IDE.

https://www.dropbox.com/s/0xy5tu4q0agcv ... 9.png?dl=0

Re: help with arduino OneButton lib

PostPosted: Thu Jul 30, 2015 3:34 am
by schufti
Hi,
thank you for the hint with the staging version, it's working like a charm now*.
yes, it's a very helpfull little lib for simplistic "user interface" like setting a clock etc.

thx to the community,
schufti

*Edit: no, not really. It is working with the example but not in my sketch that I want to move from arduino mini to esp8266 to get "time" w/o extra rtc :)