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.

Coin Marketplace

STEEM 0.20
TRX 0.15
JST 0.029
BTC 63483.25
ETH 2601.63
USDT 1.00
SBD 2.81