🛠 Première LED sur GPIO17 : banques, courants et broches réservées

Raspberry Pi Compute Module 1 (CM1) · debutant · Schéma : IMG-cm1-debutant-3-led-gpio17-cm1.svg — Le connecteur du Compute Module 1 avec la banque 0 (broches 0-27) et la banque 1 (28-45), les broches réservées GPIO46/47 barrées, et une LED avec résistance sur GPIO17

Objectives

Turn on an LED from a CM1 GPIO while understanding the pin mapping: GPIOs are divided into bank 0 (GPIO 0 to 27) and bank 1 (GPIO 28 to 45). The GPIO46 and GPIO47 lines are reserved for the system (SD/eMMC ID) and must not be repurposed. The BCM2835 allows 16 mA per pin and a total of 50 mA per bank: an LED with a 330-ohm resistor is well within limits, but a direct relay is not. We control it via sysfs, then via gpiod.

Hardware

Complete code

# Méthode sysfs (simple)
echo 17 | sudo tee /sys/class/gpio/export
echo out > /sys/class/gpio/gpio17/direction
while true; do
  echo 1 > /sys/class/gpio/gpio17/value; sleep 0.5
  echo 0 > /sys/class/gpio/gpio17/value; sleep 0.5
done

# Méthode gpiod (moderne)
gpiodetect
gpioset gpiochip0 17=1     # allume
gpioset gpiochip0 17=0     # éteint

# Rappel des limites : 16 mA/broche, 50 mA/banque, broches 46/47 interdites

Expected verification

The LED blinks at 1 Hz. cat /sys/class/gpio/gpio17/direction returns out. Trying echo 46 > export fails (line reserved for the system) — this is the expected behavior, not a failure. The resistor calculation: (3.3 V - 2 V LED drop) / ~13 mA gives approximately 100 ohms minimum; 330 ohms provide a clearly visible LED with a very safe current.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials