Debouncing

 

(A thorough treatment of the topic of button and switch debouncing is worthy of an ISP)

There are a wide variety of mechanical button and switch types that are used as inputs to digital systems. As convenient as the vast selection is, they typically suffer, to various degrees, from a characteristic known as bounce that must be addressed.

Explore the issue with this interactive site: https://deepbluembedded.com/arduino-button-debouncing/

Here's a good starter video from Digikey on the issue: What is Switch Bounce and How to Debounce

The obvious issue for a digital systems monitoring the mechanical input is to prevent it from detecting multiple state changes when only one was intended.

The solution to the problem can be handled in one of two ways: software or hardware. The video above suggests the pros and cons of each approach. Different button and switch types lend themselves to preferred strategies but, as general rule of thumb worth noting, problems that originate in hardware should be fixed with hardware (Boeing's Big Mistake?).

Hardware Debouncing Solutions

Software Debouncing Solution

Test Code for our Lesson

  1. Debounce.ino (builtin example)
  2. DebounceTestPlotter.ino
  3. DebounceTest.ino