mathertel/OneButton — pull request #2 by arjenbreur (2014-04-06 11:01:10+00:00)
Title: Added debouncing of input readings, to prevent false double clicks

Without debouncing the input reading, a single button push can read as several short button presses ("caused by a small ripple of current that forms when a mechanical switch is pushed in an electrical circuit and makes a series of short contacts"). OneButton treats such an event falsely as a double click. This commit adds a debouncing method to the class. The input reading has to stay the same (high or low) during a short timespan, before the button push is treated as an actual click. This timespan (debounce delay) defaults to 50ms, but can be set at setup/runtime. Different buttons or circuits may require different debounce delays to remove the "flickering" of the reading at first contact.