3.3.2 Debouncing

In the perfect world, when a switch changes state, it is a single event. Unfortunately, switches, such as push button switches, are mechanical devices. The contact bounces a few times before it settles. In other words, a program, polling at a relatively high frequency, sees a whole bunch of transitions for a single button push. The same is true when a button is released.

This is not good. When a button is pushed once, a program may register it as several push-and-release events. If you rely on counting events to change settings, you will have a hard time getting to the correct settings!

Instead of fixing the problem in the switches, the problem can be solved in software. Debouncing is a software technique used to ``filter out'' bounces to yield clean state change events.



Subsections

Copyright © 2006-02-15 by Tak Auyeung