clignotante.py
The getting-underway script on an SBC: an LED on the GPIO header blinks at 1 Hz. gpiozero is the reference library on this OS: it handles the GPIO chip without root tricks.
Hardware required
A Compute Module 3+ (BCM2837B0, 1 GB LPDDR4) on a Compute Module IO Board v3, powered at 5 V, running Raspberry Pi OS (Bullseye). 1 LED + 330 Ω resistor (the pins are 3.3 V on all these boards).
Wiring
LED anode on physical pin 11 (GPIO17) through 330 Ω, cathode on a GND pin (e.g. 14).
How it works
The script sets the pin as output, alternates high/low with sleep(1), and cleanly releases the pin (finally) even on Ctrl-C. On Bullseye: sudo apt install python3-gpiozero then python3 your_script.py. The CM3+ behaves like a Pi 3 B+; IO Board pins follow the BCM numbering.
Going further
Replace sleep with a pattern (PWM ramp via gpiozero PWM / gpiod + threads), or wire several LEDs in a ring.
clignotante.py
#!/usr/bin/env python3
# Clignotement LED avec gpiozero (bibliotheque recommandee sur cet OS).
# Installation : sudo apt install python3-gpiozero
from gpiozero import LED
from time import sleep
led = LED(17) # GPIO17 = broche physique 11 du connecteur
print("Clignotement : Ctrl-C pour arreter")
try:
while True:
led.on() # la broche passe a 3,3 V
print("LED ON")
sleep(1)
led.off() # la broche repart a 0 V
print("LED OFF")
sleep(1)
except KeyboardInterrupt:
print("Arret propre")
finally:
led.close() # rend la broche a l'etat au repos