🛠 Faire clignoter une LED sur la broche P8_03 avec libgpiod

BeagleBone AI-64 (TI TDA4VM / J721E) · debutant · Schéma : IMG-beaglebone-ai64-debutant-2-clignoter-led-broche-p8-03.svg — broches P8 de la BeagleBone AI-64, zoom sur P8_03 reliée via une résistance 330 Ω à une LED puis GND, mention « 3,3 V max ».

Objectives

Control a pin on the P8/P9 headers using the modern libgpiod library: identify the correct GPIO controller (the AI-64 has several), understand that P8_03 corresponds to GPIO0_20 (muxmode 7 according to chapter 7 of the System Reference Manual), and blink an LED in Python.

Hardware

Complete code

sudo apt install python3-gpiod gpiod
gpiodetect   # chercher la puce nommée 600000.gpio (contrôleur "main")
gpioinfo 600000.gpio | grep -i P8_03
#!/usr/bin/env python3
# blink.py — libgpiod v2, image Debian AI-64
import gpiod, time

# 4211000.gpio = wkup (petit contrôleur), 600000.gpio = main (broches P8/P9)
with gpiod.Chip("600000.gpio") as chip:
    line = chip.get_line(20)          # P8_03 == GPIO0_20
    line.request(consumer="blink", type=gpiod.line_request.DIRECTION_OUTPUT)
    try:
        while True:
            line.set_value(1); time.sleep(0.5)
            line.set_value(0); time.sleep(0.5)
    finally:
        line.release

Expected verification

The LED blinks at 1 Hz. During execution, gpioinfo shows line 20 of 600000.gpio as "output" with the consumer "blink". The script cleanly releases the pin upon Ctrl+C.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials