🛠 Allumer une LED depuis la GPIO 17 avec libgpiod
Objectives
Discover the 40-pin header (J8) of the Raspberry Pi Model B+ — the ribbon that defined the format for all subsequent "Model B" boards — and light up an LED without writing a program, using the libgpiod tools (gpiodetect, gpioinfo, gpioset) available on legacy 32-bit images.
Hardware
- Raspberry Pi Model B+ (BCM2835, 512 MB) running Raspberry Pi OS legacy 32-bit (Buster or earlier)
- 1 red LED, 1 330 Ω resistor, female-to-male Dupont wires
- Reliable 5 V micro-USB power supply (undervoltage cuts distort everything)
Complete Code
# Installation des outils libgpiod
sudo apt update && sudo apt install -y gpiod
# Inventaire des puces GPIO puis état des lignes
gpiodetect
gpioinfo gpiochip0
# Broche physique 11 = GPIO17 (BCM) : mise à 1, la LED s'allume
sudo gpioset gpiochip0 17=1
sleep 5
# Extinction
sudo gpioset gpiochip0 17=0
Wiring: pin 11 (GPIO17) → 330 Ω resistor → LED anode; cathode → pin 14 (GND). The B+ logic operates at 3.3 V: never supply a GPIO pin with 5 V.
Expected Verification
gpiodetect displays "gpiochip0 [bcm2835-gpio] (54 lines)". After running gpioset gpiochip0 17=1, the LED stays lit and gpioinfo shows line 17 as "output active"; with 17=0 it turns off.
Common Errors
- Forgetting sudo: "permission denied" on /dev/gpiochip0 (or add the user to the gpio group).
- Confusion between BCM number (17) and physical pin number (11): check with gpioinfo or a pinout diagram.
- LED connected without a resistor, or pin connected to 5 V: LED destroyed or pin out of specification (3.3 V max).
- Very old image: the tools might be named libgpiod-utils instead of gpiod.
Other tutorials for this board
- Lire un bouton et afficher les appuis dans la console
- Premier script Python : faire clignoter la LED
- Variation d'intensité d'une LED avec le PWM matériel (GPIO18)
- Interroger un capteur I2C (BME280) sur le bus du 40 broches
- Mettre le B+ en réseau par Ethernet et piloter en SSH
- Amorçage microSD, pannes de boot et procédure de recouvrement
Code examples for this board
led_blink.pyPythonbutton_led.pyPythonservo_sweep.pyPythondht_temp.pyPythonoled_i2c.pyPythonmcp3008_read.pyPython