Implementing software debouncing logic

One of the common tasks of embedded applications is interacting with external physical controls such as buttons or switches. Though such objects have only two states – on and off  detecting the moment a button or switch changes state is not as simple as it may look.

When a physical button is pressed, it takes some time before the contact is established firmly. During this time, spurious interrupts can be triggered as if the button is bouncing between on and off states. Instead of reacting to every interrupt, an application should be able to filter out the spurious transitions. This is called debouncing.

Though it can be implemented at the hardware level, the most common approach is to do this through software. In this recipe, we will learn how to implement a simple and generic debouncing function that can be used with any type of input.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.12.240