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 buttons 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 button to a pin with an external interrupt enabled, you will get several interrupts when you press the button once. This behavior is normally not wanted. Even if the button’s 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 button as well. One… Continue reading