Hardware Reference
In-Depth Information
When a GPIO pin is set as an input, such as with a basic push-button example, you
can have these voltage incompatibility problems. The circuit in Figure 6-4 is wrong,
because when you press the button, the GPIO input is connected to 5 volts, which
might damage the device.
Figure 6-4.
Incorrect circuit
You can avoid damage by using a resistor in the push-button cable. The value of the
resistor is determined by the leakage current of the GPIO pin (the current used by the
circuit to read the pin) and the amount of voltage drop it creates as a result. With the
5K resistor, you obtain 3.3 V in the GPIO input because Vgpio = 5 V·(10K/(10K+5K))
= 3.3 V. Figure 6-5 shows a correct circuit.
Figure 6-5.
Correct circuit
Search WWH ::




Custom Search