Debouncing Switches

Very often we need to connect some type of mechanical switch to an Arduino as an input device. Also very often, there is mechanical slop in a switch, so the arduino sees one activation of the switch as multiple activations. This is called switch bounce. You can write code that looks at the state of the switch, saves it to a variable and waits for a short period of time and looks again to see if the button is still pressed, or you can debounce in hardware and save code space and complexity.


Leave a Comment.