GPIO
This guide shows how to find GPIO pins on the board's 40-pin header and check whether their GPIO lines are available. You'll use the Linux shell to set an output high or low and read the state of an input.
Before You Start
Open a shell on the board. This guide
uses the libgpiod 2.x command-line tools. Run gpioset --version to check the
installed version.
Check the header orientation, pinout, and GPIO voltage limits before using the header.
See Hardware Resources for the board datasheet and schematic.Board Header Mapping
The diagram shows each pin's physical number and default function. Use the
Linux GPIO line name from the Label column in commands such as gpioinfo
and gpioset.
Set an Output
This example uses physical pin 7. Check that its GPIO line is free:
gpioinfo --strict '40PIN_GPIO4'
If the line has a consumer, use a different GPIO. Otherwise, drive the pin high:
gpioset --strict '40PIN_GPIO4=1'
The command stays running and holds the output high.
Press Ctrl+C to release the line. To drive it low, run the
same command with =0. The pin level may change when gpioset exits.
Read an Input
This example reads physical pin 13. You can test it with a short jumper wire. Connecting pin 13 to GND (pin 14) gives a low level, and connecting it to 3.3 V (pin 17) gives a high level. Before connecting the jumper, check that the GPIO line is free and the pin is configured as an input.
gpioinfo --strict '40PIN_GPIO27'
Connect the jumper, then read the input.
gpioget --strict '40PIN_GPIO27'
The command reports the logical state, active (1) or inactive (0), and
exits. A floating input can return either value.