Mechanical switches are one of the most common components used in electrical and electronics manual control circuits. When you press a mechanical switch, two metal parts come in contact with each other, and the current flows through the contacts. But sometimes the metal parts connect and disconnect several times before the actual stable connection is made. The same thing happens while releasing the switch button. The mechanical switch bounce or contact bounce, sometimes called chatter, is a common problem associated with mechanical switches and relays.
Note that each switch has its own characteristics regarding the bounce. For example, you may have two similar switches, but there is a high chance that each will bounce differently. These problems are very common in digital and microcontroller circuits associated with the mechanical switch. These chattering inputs are electrically cleansed with a switch debouncer circuit to prevent or reduce false triggering or multiple triggering.
One of the simplest solutions is adding a resistor and capacitor (RC) across the switch, as shown in Fig. 1. Here, the RC circuit acts as a filter to smooth out the output glitches. When the switch is open, the voltage across the capacitor remains zero. Initially, the capacitor charges through the resistors (Rp and Rd).
When the switch is closed, the capacitor starts discharging through Rd, and hence the voltage output (Vout) becomes high. In the bouncing condition, the capacitor stops the voltage at the input voltage (Vin) until it reaches Vcc or ground, preventing false triggering.