🛠 Allumer une LED depuis le GPIO 26 broches
Objectives
- Understand the 26-pin (P1) pinout of the older Raspberry Pi Model A, compared to the 40-pin header on recent models.
- Turn an LED on and off from the command line using libgpiod tools.
- Write a small bash script to blink the LED.
Hardware
- Raspberry Pi Model A (BCM2835, 26-pin GPIO, 3.3 V logic only).
- 1 red LED + 1 330 Ω resistor.
- Jumper wires, proper 5 V micro-USB power supply.
- HDMI screen or serial console on the GPIO UART for input.
Complete code
# Vérifier la présence de la puce GPIO
sudo apt-get install -y gpiod
sudo gpiodetect && sudo gpioinfo
# Broche 11 du connecteur P1 = GPIO17 (BCM)
sudo gpioset gpiochip0 17=1 # LED allumée
sleep 2
sudo gpioset --mode=exit gpiochip0 17=0 # LED éteinte
# Clignotement
while true; do
sudo gpioset --mode=exit --time 500000 gpiochip0 17=1
done
Expected verification
gpiodetect displays gpiochip0 [brcm2835] (54 lines); the LED turns on with 17=1 and off with 17=0. >
Common errors
- Confusing the numbering: physical pin 11 = GPIO17 (BCM), not GPIO11.
- Forgetting the resistor: the LED burns out or draws too much current from the 3.3 V pin.
- Reversing the LED anode/cathode (long leg = anode).
- Using a 5 V pin where the logic is 3.3 V; the Model A has no ADC.
Other tutorials for this board
Code examples for this board
led_blink.pyPythonbutton_led.pyPythonservo_sweep.pyPythondht_temp.pyPythonoled_i2c.pyPythonmcp3008_read.pyPython