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 ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.