🛠 Faire clignoter une LED via le GPIO
Objectives
Discover the 40-pin GPIO connector on the ODROID-N2 (Amlogic S922X) by blinking an LED. Under a mainline image (Armbian), the BayLibre device-tree assigns readable PIN_xx names to GPIO lines, avoiding any pin number calculation: you directly control PIN_23 (GPIOX_11) with libgpiod v2.
Hardware
- ODROID-N2 or N2+ running Armbian (mainline kernel, meson-g12b family)
- 1 red LED + 1 330 Ω resistor
- Female-to-male Dupont cables
- Warning: GPIO logic level not confirmed (3.3 V generally accepted) >
Complete code
#!/usr/bin/env bash
# clignotant.sh — LED sur PIN_23 (GPIOX_11), GND sur PIN_25 — libgpiod v2
set -e
# 1. Vérifier que le chip expose bien les noms lisibles du device-tree
gpioinfo gpiochip0 | grep -E 'PIN_(23|25)'
# 2. Clignoter : cycle 0,5 s
while true; do
gpioset --quiet gpiochip0 PIN_23=1; sleep 0.5
gpioset --quiet gpiochip0 PIN_23=0; sleep 0.5
done
Expected verification
gpioinfo gpiochip0 | grep PIN_23 displays the line named PIN_23 (GPIOX_11). After running sudo ./clignotant.sh, the LED blinks at 1 Hz; Ctrl-C stops it. gpioset --quiet gpiochip0 PIN_23=0 should turn off the LED.
Common errors
- Wrong pin: the connector has 40 pins, count from the corner marked 1 (near the Ethernet port).
- Missing resistor: the LED burns out or draws too much current.
- LED reversed: the long leg (anode) goes to PIN_23, the short leg to GND (PIN_25).
gpiochip0not found: on some images the chip has a different name, list them withgpioinfoorls /dev/gpiochip*.- Vendor image (Hardkernel kernel 4.9):
PIN_xxnames do not exist, use Hardkernel tools or switch to Armbian. - Permissions: add the user to the
gpiogroup or run with sudo.
Other tutorials for this board
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash