xerxes-nano-gpio-led-blink.py

Xerxes Nano Carrier Board for Jetson Orin Nano Super and Turing RK1 Modules · File : xerxes-nano-gpio-led-blink.py · Language : Python · Use case : Allumer et éteindre une LED connectée sur un GPIO pour tester la sortie numérique.

Python script using Jetson.GPIO library to blink an LED on GPIO pin 18.

Hardware: LED with 330Ω resistor between GPIO 18 and GND. Software: JetPack or Ubuntu with python3-jetson-gpio installed. Execution: sudo python3 script.py. Check pinout numbering in Xerxes Nano documentation.

xerxes-nano-gpio-led-blink.py

#!/usr/bin/env python3
"""
Exemple de contrôle GPIO pour Xerxes Nano (Jetson Orin Nano / Turing RK1).
Utilise la bibliothèque Jetson.GPIO (ou RPi.GPIO compatible) pour clignoter une LED.
"""
import time
import Jetson.GPIO as GPIO

# Pin GPIO 18 (numérotation BCM)
LED_PIN = 18

def setup():
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(LED_PIN, GPIO.OUT)
    print(f"GPIO {LED_PIN} configuré en sortie.")

def loop():
    try:
        while True:
            GPIO.output(LED_PIN, GPIO.HIGH)
            print("LED ON")
            time.sleep(0.5)
            GPIO.output(LED_PIN, GPIO.LOW)
            print("LED OFF")
            time.sleep(0.5)
    except KeyboardInterrupt:
        print("\nArrêt demandé.")
    finally:
        GPIO.cleanup()
        print("GPIO nettoyé.")

if __name__ == "__main__":
    setup()
    loop()

← Back to the board