Hardware Reference
In-Depth Information
You use a pull-up circuit instead of a pull-down in this example and invert the
output later. FigureĀ 12-2 shows the button signal being probed with an oscillo-
scope. When I press the button, it bounces up and down before finally settling
at a low state.
Figure 12-2: Ordinary pushbutton bouncing before settling
If you trigger an interrupt off this signal, it executes the interrupt function
three times in a row. But, using something called a resistor-capacitor network
(commonly called an RC circuit), you can prevent this.
If you connect a capacitor across the terminal of the switch and a resistor in
series with the switch, it creates a resistor-capacitor network. While the switch
is not pressed, the capacitor charges through the resistors. When you push the
button, the capacitor starts to discharge, and the output goes high. If the button
bounces up and down for a few milliseconds, the resistors recharge the capacitor
while the switch momentarily opens, allowing it to maintain the voltage level
at the output. Through this process, you get a signal that transitions between
high and low only one time in a period determined by the values of the resis-
tor and capacitor. Such a circuit would look like the one shown in FigureĀ 12-3.
Search WWH ::




Custom Search