When you close a pair of contacts on a switch, the contacts tend to bounce and make intermittent contact before their spring loading is fully applied and the contacts settle in the closed state. Under normal circumstances this is not a problem and LEDs, motors or other devices usually accommodate the bouncing without becoming too excited. However, if you're trying to count the number of times the switch closes, for example on a rotary encoder or a reed switch, contact bounce becomes a problem and must be resolved. You can use debounce mitigation measures in either software or hardware. Software generally takes two measurements a short time apart and takes the later status if it's the same as the earlier one. This page deals with a hardware solution and describes what needs to be added to the switching circuit to eliminate contact bounce, or at least reduce its impact to a manageable level.

The principle of the debounce hardware is to charge a capacitor when the contacts first make the circuit. The charge in the capacitor then keeps the circuit live even though the contacts may bounce and open again. Since the length of time that the contacts might remain open is short, the capacitor's charge does not have to last very long - only long enough until the contacts close again. However, the size of capacitor needs to be chosen correctly or you can damage the switch contacts by applying, what is in effect, a short circuit of brief duration while the capacitor is being charged. A capacitor of perhaps 100pF is usually suitable.

Circuit will be available soon!

The circuit below shows how to connect the switch and its associated debouncing components.