GPIO Zero Python library

GPIO Zero is a Python library for beginners, used to control the GPIO interface of the Raspberry Pi;

It provides a simple and easy-to-use interface for controlling peripheral devices such as LEDs, buttons, servos, motors, and various sensors.

1. Install GPIO Zero

GPIO Zero is installed by default in Raspberry Pi OS desktop images and Raspberry Pi OS Lite images.

image-20231219185949956

2. GPIO pin arrangement

Open the terminal and run the command: pinout

image-20231219190515281

3. Pin number

The GPIO Zero library uses Broadcom (BCM) pin numbers instead of physical (BOARD) numbers: that is, to control GPIO17, you need to specify 17 instead of 11 for the pin number in the program.

image-20231219193916187

Note: When using the Raspberry Pi GPIO pins, you need to pay attention to the pin connection method between the module and the Raspberry Pi motherboard to prevent damage to the motherboard.

4. Import the GPIO Zero library

5. Reference materials

For more GPIO pin usage, please refer to the tutorial provided on the official website of the GPIO Zero library!