🛠 Faire clignoter la LED de statut via GPIO

Orange Pi PC (Allwinner H3) · debutant · Schéma : IMG-orangepi-pc-debutant-1-opipc-led-gpio.svg — Orange Pi PC avec la LED rouge de statut (PA15) reliée au contrôleur GPIO du H3, broches 5V et GND du connecteur 40 broches surlignées.

Objectives

Understand how the Orange Pi PC controls its GPIO pins and make the red status LED blink (PA15, named "orangepi:red:status" in the mainline device tree). You will learn the two possible approaches: libgpiod (recommended under Armbian/mainline) and WiringOP (the wiringPi fork maintained by Xunlong for Orange Pi).

Hardware

Complete Code

libgpiod approach (no proprietary library):

sudo apt install gpiod
# PA15 = broche 15 de gpiochip0 (banque PA)
gpioset "$(gpiofind PA15)" 1; sleep 0.2; gpioset "$(gpiofind PA15)" 0
# Boucle de clignotement
while true; do gpioset "$(gpiofind PA15)" 1; sleep 0.5; gpioset "$(gpiofind PA15)" 0; sleep 0.5; done

WiringOP approach in C (sunxi numbering: PA15 = 0×32 + 15 = 15):

/* blink.c — LED PA15 via WiringOP */
#include <wiringPi.h>
#define STATUS_LED 15
int main(void) {
    if (wiringPiSetupG == -1) return 1;
    pinMode(STATUS_LED, OUTPUT);
    for (;;) {
        digitalWrite(STATUS_LED, HIGH);
        delay(150);
        digitalWrite(STATUS_LED, LOW);
        delay(150);
    }
}
git clone https://github.com/orangepi-xunlong/wiringOP && cd wiringOP
./build && sudo ./build install
gcc -O2 blink.c -o blink -lwiringPi && sudo ./blink

Expected Verification

The red LED on the board blinks approximately 3 times per second. With gpioinfo, you see gpiochip0 (banks PA to PH) and gpiochip1 (r_pio). The PA15 line switches to output mode.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials