JC_Button
JC_Button copied to clipboard
Not immune to noise :(
Hello Jack
I've been using and recommending this library for years, but recently had a problem with buttons in a project using this library, and after investigating I found that the problem lies in your debounce code.
The problem is that button press/release changes are detected immediately, your code only prevents multiple changes during the debounce time. Therefore, it's not immune to noise!
To be clear, I always thought the button press/release was detected after the debounce time, not before, to wait for the button state to be stabilized.
Here is a Wokwi demo with the debounce time set to one second : https://wokwi.com/projects/353568497230783489