Software Debouncing of buttons

Connecting a button as an input to a micro-controller is a relatively easy task, but there are some problems. The main problem is that switches bounce, i.e., when you press (or release) a button it will often change level a couple of times before it settles at the new level. So if you, for example, connect the switch to a pin with an external interrupt enabled, you will get several interrupts when you press the button once. This behavior usually is not wanted. Even if the buttons didn’t bounce (with filtering hardware for example) we still want to capture the event of a pushed button and take some action one time for every button press, so we need to keep track of the state of the switch as well. One… Continue reading