ElectricRCAircraftGuy / eRCaGuy_EventReader

-the most thorough and robust button and event debouncing algorithm for Arduino that man has ever known :)
1 stars 2 forks source link

Debouncing info: update readme with an explanation of debouncing #2

Open ElectricRCAircraftGuy opened 2 years ago

ElectricRCAircraftGuy commented 2 years ago

If anyone needs a verbal explanation of bouncing, debouncing, or how a basic debounce algorithm works, let me know. I love debouncing buttons. I think it's a lot of fun, and requires an understanding of interesting electrical and mechanical properties.

Note that if anyone says "but I have a low-pass filter via resistor and capacitor to debounce the button in hardware, so we don't need debouncing in software", they are wrong. Hardware debouncing can significantly help, but is not foolproof. Software debouncing is foolproof when done right. Add the logic to also debounce in software anyway. It's not that hard.

Debounce logic I wrote in 2016, before I was as good at coding--so please don't judge too harshly--but the debounce logic is sound: https://github.com/ElectricRCAircraftGuy/eRCaGuy_EventReader/blob/master/eRCaGuy_EventReader.cpp#L101-L160

Adafruit debouncing background, explanation, and a code library called adafruit_debouncer: https://learn.adafruit.com/debouncer-library-python-circuitpython-buttons-sensors?view=all

I labelled this image which was from the article above:

Selection_520

ElectricRCAircraftGuy commented 1 year ago

Update: see my content here: https://github.com/ElectricRCAircraftGuy/eRCaGuy_hello_world/blob/master/electronics/event_and_button_debouncing.md