gpio-led-control-python.py
Python script using libgpiod to blink an LED connected to the internal GPIO pins of the board.
The PICO-PTH4 has internal GPIO connectors. Install 'libgpiod' and 'python3-gpiod'. Check pin numbers in the AAEON technical manual. Run with sudo if needed.
gpio-led-control-python.py
#!/usr/bin/env python3
"""
Contrôle GPIO basique sur AAEON PICO-PTH4.
Nécessite le module 'gpiod' (libgpiod) installé sur le système Linux.
Les broches GPIO sont exposées via un connecteur interne (à identifier via le schéma électrique).
"""
import gpiod
import time
import sys
# Nom du chip GPIO par défaut (à vérifier avec 'gpiodetect')
CHIP_NAME = 'gpiochip0'
# Numéro de la ligne GPIO (à adapter selon le schéma de la carte)
GPIO_LINE = 17
def main():
try:
# Ouvrir le chip GPIO
chip = gpiod.Chip(CHIP_NAME)
# Demander la ligne en sortie
line = chip.get_line(GPIO_LINE)
line.request(consumer='pico_led', type=gpiod.LINE_REQ_DIR_OUT, default_val=0)
print(f"Contrôle de la ligne GPIO {GPIO_LINE} sur {CHIP_NAME}")
while True:
line.set_value(1) # Allumer
time.sleep(1)
line.set_value(0) # Éteindre
time.sleep(1)
except Exception as e:
print(f"Erreur: {e}")
print("Assurez-vous que libgpiod est installé et que les permissions GPIO sont correctes.")
finally:
if 'line' in locals():
line.release()
if 'chip' in locals():
chip.close()
if __name__ == "__main__":
main()