In this example we create a simple filtering class for Arduino to debounce buttons, after using MegunoLink’s XY Plot library and visualiser to observe the false button activation caused by button bounce.

The Button Bounce Problem

Button bounce refers to multiple high-low transitions in the output signal of a switch as it is pressed or released, in addition to the single transition expected. The signal ‘bounces’ before it finally settles at it’s new level. This is typically caused by mechanical bouncing in the switch. The debounce class eliminates the extra transitions so we get a clean change.

Button debounce is needed for this signal

Mechanical switches bounce between on and off for a short time after they are pressed. The debounce class will clean this up.

These additional fast transitions are a problem in high speed systems, especially edge-sensitive ones. For example, a high speed counter would count six high-low transitions or ‘button presses’ in the button bounce signal plotted above, as opposed to the single button press by the user.

The delay method of debouncing buttons in software involves waiting for the signal from the button to stabilise before taking action. A simple delay-based button debounce class using the ArduinoTimer feature of the MegunoLink Arduino library can be found in the below example for your debouncing convenience.

Downloads

This example requires our Arduino Library. You can download a ZIP file containing the button debounce Arduino program and bonus bounce plotting Arduino program with MegunoLink interface below.

ButtonDebounce
ButtonDebounce
ButtonDebounce.zip
Version: 1
4 KiB
67 Downloads
Details

An Arduino Debounce Class

Recent Posts

Leave a Comment

Start typing and press Enter to search