Software Debounce

Second time lucky!

The attached sketch implements a software debounce, using cactusjack's Elegant debouncing solution with software Schmitt trigger emulation.

The filter uses two chained low-pass filters, a trigger, and I also tweaked it by adding code to saturate the filters when a state change occurs, hopefully adding more insurance against bouncing.

The sketch requires an input button, and four output LEDs.

The first LED is the data off the input button, sampled at 4ms intervals.
The second LED shows the input data with 25% of the bits discarded and replaced with random noise.
The third LED shows the result of debouncing. It's clean and slightly delated.
The fourth LED counts the clicks by flashing 250ms.

Movie at Arduino software debounce - YouTube (hopefully).

software_debounce.ino (6.49 KB)

1 Like