-
Notifications
You must be signed in to change notification settings - Fork 9
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.onReleased() is true before the button is ever pressed #14
Comments
This could be any number of problems:
I’d check all of these things. Let me know if you find the problem or if your are still stuck. |
Alex, your sample works fine, but mine doesn't. I wonder if there's something special about GPIO 11 on my board? |
Sorry about closing this issue, that was an accidental click. Try changing pins, or buttons, or rewiring it. Do you have a different Arduino board to test the button? |
When I start with your example sketch, and change the pin to 11, it works. When I take my own sketch, and remove everything else, it doesn't work. The only difference I see from your sample is the Your .cpp file looks fine too. I solved it with a flag that gets set to true the first time the button is pressed, but that's messy in my own code. Maybe we just need to add that state flag to the library? Have you heard of this issue from anyone else? |
Do you need to include stdio.h? If you take that out does the the button behave properly? |
It still happens if I don't include #stdio.h |
I also encountered this on esp8266 and esp32, but works fine on uno |
I have same issue on Arduino IDE + RP2040:
|
@peter58228 There are a few things going on here...
In summary; your code won't register button events because you use Also, there are several other reasons why your code might not work as intended. You could have wiring issues or a faulty Arduino board... or you most likely have normally closed buttons. They are "pressed" by default and when you push the button it opens the circuit. If this is the case you should run this code once in your void setup() {
for (int i = 0; i < 16; i++) {
btn[i].invertReading();
}
} Let me know if you are still having issues after adjusting your code. Others have reported this issue and I still think there might be hardware or library compatibility issues across all of the different flavors of Arduino development. |
This is strange. In the example program, button.onReleased() is only called after the button is pressed.
But in my sketch, button.onReleased() is true the first time through my loop(), before the button has been pressed.
I'm using an Adafruit m0 board, and pin 11 is a standard GPIO pin (docs)
The text was updated successfully, but these errors were encountered: