Switch Debouncing Via Software

How can we easily debounce those pesky mechanical switches without using external components and without tying up processor cycles in a wait loop?

The answer is easy. We can use a virtual shift register. The I/O pin the switch is connected to is sampled at periodic intervals and its logic level at that instant is shifted into a virtual shift register. Once all bits of the shift register are 0 or 1, the switch is considered to have settled into an on or off state, respectively.



0
0
0.000
0 comments