🛠 Allumer une LED via le GPIO avec libgpiod

Raspberry Pi Model B (Rev 1, 2012) — Board Sheet · debutant · Schéma : IMG-model-b-rev1-debutant-1-modelb1-led-gpio-libgpiod.svg — Raspberry Pi Model B Rev 1, connecteur P1 26 broches, GPIO17 (broche 11) vers résistance 330 Ω puis LED vers GND (broche 6)

Objectives

Discover the 26-pin GPIO connector (P1, 2×13) on the Raspberry Pi Model B Rev 1 and turn on an LED from the command line using libgpiod, the modern method that replaces the older wiringPi. You will understand BCM numbering (Broadcom pin numbers) and the difference between data pins and power pins.

Hardware

Complete code

# Installation de libgpiod (Buster)
sudo apt update && sudo apt install -y gpiod

# Lister les broches du contrôleur BCM2835
gpioinfo gpiochip0

# Configurer GPIO17 en sortie puis l'allumer (GPIO17 = broche physique 11)
gpioset gpiochip0 17=1
sleep 3
gpioset gpiochip0 17=0

Expected verification

The LED turns on for 3 seconds and then turns off. gpioinfo gpiochip0 shows pin 17 changed from input to output. The wiring diagram: GPIO17 (pin 11) → 330 Ω resistor → LED anode → cathode → GND (pin 6).

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials