Open PeteHaughie opened 1 year ago
My particular use case is trying to software debounce a button press but I'm not sure how I would go about it using your library. Is there a way of utilising the lib in this way?
Absolutely. You simply need to use the timestamps to measure time intervals between button bounces (changes of state). Once the button state has not changed in a long time--ex: 50ms, you can assume it is done bouncing, and the state at that instant is the actual state.
Here's a debounce library I wrote a while back (be gentle: it was before I knew so much about programming and software design): https://github.com/ElectricRCAircraftGuy/eRCaGuy_EventReader
The interface may not be ideal, but the debounce algorithm is solid.
Simply replace the usage of millis()
in this file here with a timestamp call from the timerCounter library: https://github.com/ElectricRCAircraftGuy/eRCaGuy_EventReader/blob/master/eRCaGuy_EventReader.cpp
I'm building an electronic instrument with an Uno I had lying about. To create tones I'm using the Mozzi library which I think hijacks the internal timer for PWM because when I poll millis I always get a return of 0. I saw your post in an old thread from about a decade ago which mentioned a similar issue and thought I'd try it out. My particular use case is trying to software debounce a button press but I'm not sure how I would go about it using your library. Is there a way of utilising the lib in this way?