Hi Rhubarb65, I have been using this algorithm for quite a while now with great results:
http://www.kennethkuhn.com/electronics/debounce.c
Please find one example/implementation here:
Originally published at: https://blog.particle.io/2019/02/20/learn-how-to-use-these-sensors/
Editor’s note: Most IoT projects will have at least one sensor in their bill of materials (BoM). Sensors come in all shapes and varieties. Most sensors mimic your sensory perception like a PIR motion sensor, but do so in super-human ways. A PIR sensor use infrared light to see objects. Other sensor are more like giving your project super powers.
Author Gustavo Gonnet presents how to use a handful…
And the source code is here .
EDIT: if you feel like reading some "science" behind debouncing an input, you can do so here (excellent source of info by the way). I got the method I use from that guide.
2 Likes