Pull-up and pull-down resistor circuits

The previous code sets the GPIO pins to use an internal pull-up resistor. Without a pull-up resistor (or pull-down resistor) on the GPIO pin, the voltage is free to float somewhere between 3V3 and 0V, and the actual logical state remains undetermined (sometimes 1 and sometimes 0).

Raspberry Pi's internal pull-up resistors are 50K ohm-65K ohm, and the pull-down resistors are 50K ohm-65K ohm. External pull-up/pull-down resistors are often used in GPIO circuits (as shown in the following diagram), typically using 10K ohm or larger for similar reasons (giving a very small current draw when they are not active).

A pull-up resistor allows a small amount of current to flow through the GPIO pin and will provide a high voltage when the switch isn't pressed. When the switch is pressed, the small current is replaced by the larger one flowing to 0V, so we get a low voltage on the GPIO pin instead. The switch is active low and logic 0 when pressed. It works as shown in the following diagram:

A pull-up resistor circuit

Pull-down resistors work in the same way, except the switch is active high (the GPIO pin is logic 1 when pressed). It works as shown in the following diagram:

A pull-down resistor circuit
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.147.215