gpio-led-status-indicator.py
Python script using the RPi.GPIO library to blink an LED connected to a GPIO pin on the Compute Module 5.
This module requires the Raspberry Pi Compute Module 5 mounted on the Smart Display Module. Ensure the RPi.GPIO library is installed via 'pip install RPi.GPIO'. Connect an LED with a series resistor to GPIO pin 17 (BCM) and ground. Run the script with sudo python3 gpio-led-status-indicator.py for GPIO access permissions.
gpio-led-status-indicator.py
import RPi.GPIO as GPIO
import time
import sys
# Configuration des broches GPIO
# Note: Utiliser les numéros de broches physiques (Board) ou BCM selon le schéma du Compute Module 5
LED_PIN = 17 # Exemple de broche GPIO
def setup():
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(LED_PIN, GPIO.OUT)
def blink(count=5):
try:
for _ in range(count):
GPIO.output(LED_PIN, GPIO.HIGH)
time.sleep(0.5)
GPIO.output(LED_PIN, GPIO.LOW)
time.sleep(0.5)
except KeyboardInterrupt:
pass
finally:
GPIO.cleanup()
if __name__ == '__main__':
setup()
print("Clignotement de la LED de statut...")
blink()
print("Terminé.")