-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Button doesn't work as desired #1
Comments
I found that if I explicitly set the button pin mode as INPUT_PULLUP the button works as it should. |
Hi, About the INPUT_PULLUP problem, did you set the pinMode to INPUT_PULLUP explicitly in this line and make the button works as expected? My button hardware is using INPUT rather than INPUT_PULUP. Could you help me to test this code, changing the pin_activeType to _pin_activeType may help?
or this?
Maybe I should not use HIGH, LOW with bool data type. I will address this issue in the future. |
To make it work, I simply but this line in the setup of the NSEncoder_btn.ino |
@gitterman , Thank you for fixing the bug in this project.😆 I see your point. So, the problem is a logical problem rather than a code/hardware problem? Just flip the order in this line, when the _pin_activeType is LOW thwn the arduino will use INPUT_PULLUP to handle the input connection. In short, the following modification can solve the problem?
to
If yes, I will make a commit to fix this problem. |
Yes, reversing the logic solves the problem. |
Thank you for your help, I will update the main branch after I tested the new code. (around 1-2 weeks) |
Hi @lesterlo. I'm having the same issue reported by @gitterman. Did you test the code and updated it? Thanks, Max |
JFYI, I checked my NSEncoder_btn.cpp downloaded few weeks ago and, as of today, that fix has not been applied. |
Currently, I don't have the hardware in my hands. Let me check it when getting it. thank you very much |
Hi Lesterlo.You don’t need the hardware to compile.Just select the DUE platform in the Arduino IDE.Let me know if i can help.MassimoOn Mar 5, 2023, at 6:55 AM, Lester Lo ***@***.***> wrote:
Currently, I don't have the hardware in my hands. Let me check it when getting it.
thank you very much
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
I tried the examples with my encoder attached to A1 and A2 and the button attached to A0.
The examples without button do work but when I use the button example I see button status messages although I do not touch the encoder.
I mostly get "Btn status: Held"
When I press the button several times I sometimes manage to get "Btn status: Released".
If I then rotate the encoder I get the encoder output as desired but intermixed with "Btn status: Pressed" messages although I did not press the button.
I set enable_doublePress=false but did not get any improvement.
I also uncommented the intervals for the button in setup as I noticed that they are different from the definitions in NSEncoder.h but no change either.
If I use the ClickEncoder library from 0xPIT the button works as it should. Thus, I think the encoder hardware is OK.
Here is an excerpt from the serial monitor:
Btn status: Held
Btn status: Held
Btn status: Held
Btn status: Held
Btn status: Held
Btn status: Held
Btn status: Held
Btn status: Held
Btn status: Held
Btn status: Released
Encoder Diff: 1
Encoder Diff: 1
Encoder Diff: 1
Encoder Diff: -1
Encoder Diff: -1
Btn status: Pressed
Encoder Diff: -1
Btn status: Pressed
Encoder Diff: -1
Encoder Diff: -1
Btn status: Pressed
Encoder Diff: 1
Encoder Diff: 1
The text was updated successfully, but these errors were encountered: