Electronics: How to Debounce a Clock Input
When you use a mechanical switch to trigger the electronic clock input of a flip-flop, the switch will very likely have some mechanical bounce. This bounce happens when the switch contacts don’t close completely cleanly; instead, the contacts bounce a little bit when they first touch each other.
Even though these bounces are usually just a few milliseconds apart, they can end up confusing the flip-flop, as it thinks that each bounce of the switch contacts is actually a separate press of the button.
So instead of just turning the LED attached to the Q output from off to on, a single press of the button might turn it from off to on, and then back off, then on, then off again, and so on until the switch settles down into its fully-closed position.
There are several different ways you can debounce a mechanical switch — that is, eliminate the bounce effect. The easiest is to connect the mechanical switch to a one-shot timer circuit that uses an RC network to create a very short time interval such as 10 or 20 ms. Though short, this interval is enough to eliminate the negative bouncing effect.