🛠 Allumer une LED via le GPIO avec libgpiod

Raspberry Pi 5 (model-5) · debutant · Schéma : IMG-model-5-debutant-1-model5-d1-led-gpio-libgpiod.svg — Raspberry Pi 5, broche physique 11 (GPIO17) vers résistance 470 Ω puis LED vers GND

Objectives

Discover the 40-pin GPIO header of the Raspberry Pi 5 and turn on an LED from the command line using libgpiod, the modern Linux kernel GPIO API. On the Pi 5, the 3.3 V pins are controlled by the RP1 chip, and the logic is 3.3 V only.

Hardware

Full code

# Installer les outils libgpiod
sudo apt update && sudo apt install -y gpiod

# Vérifier la puce GPIO (gpiochip0 sur Pi 5)
gpiodetect
gpioinfo gpiochip0 | grep -A1 line\ 17

# Mettre GPIO17 en sortie et l'allumer (broche physique 11)
gpioset gpiochip0 17=1
sleep 2
gpioset gpiochip0 17=0

# Clignoter 5 fois
for i in 1 2 3 4 5; do gpioset --hold-period 1s gpiochip0 17=1; done

Expected verification

gpiodetect displays gpiochip0 [pinctrl-rp1]. The LED lights up during gpioset with 17=1 and then turns off. With --hold-period 1s, it blinks for one second per cycle.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials