Logic Gates may be used to remove
oscillations or unwanted pulses (bouncing) produced by mechanical
switches and relays during the mechanical switching process. Below
is an
example of a switch debouncing circuit that utilizes NOR gates.

Figure 1. Bounce-free
Mechanical Switching with NOR Gates
Figure 1
shows a circuit that uses two NOR gates to stabilize the output of a
mechanical switch or relay. The output of the circuit as shown
is '0'. Thus, at this point, X1 is '0'.
When the switch is thrown from '0' to '1', the 3.3 k-ohm resistor pulls
up Y1 to '1', causing the output of NOR A to switch from '1' to '0'. This
also causes X2 to go to '0'. However, the output of the circuit (which
is the output of NOR B) remains at '0' until the instant the mechanical
switch pulls Y2 to ground. Once this happens, both X2 and Y2 will be
'0', causing the output of NOR B to go to '1'.
At this
point, X1 also goes to '1', keeping the output of NOR A at '0' and the
output of NOR B at '1'. In effect, the switching action of
the mechanical switch was transformed by the two NOR gates into a clean
digital transition from '0' to '1' at the circuit's output.
Throwing the
mechanical switch back to '0' causes Y1 to go to '0' and Y2 to go to
'1'. This causes the output of the circuit (output of NOR B) to go to '0'. This
causes X1 to go to '0', which forces the output of NOR A to go to '1'
since Y1 is also '0' at this point. The change of NOR A's output to '1'
stabilizes the output of the circuit at '0'.
Again, the mechanical switching action was transformed by the circuit
into a clean digital transition from '1' to '0'.