🛠 Allumer une LED via le GPIO
Objectives
Blink an LED on the ODROID-XU4 using the wiringPi fork maintained by Hardkernel, or libgpiod under Armbian. You will learn how to identify GPIO pins with gpio readall (or gpioinfo) and respect the pin voltage levels.
Hardware
- ODROID-XU4 powered by a 5 V/4 A adapter (5.5/2.1 mm barrel)
- 1 LED + 330 Ω resistor + Dupont wires
- Armbian image (kernel 6.6.x) or Ubuntu Hardkernel
- The board has a 30-pin header (GPIO, IRQ, SPI, ADC) and a 12-pin header (GPIO, I2S, I2C)
Complete code
/* blink.c — clignotement LED via wiringPi (fork Hardkernel)
* Build : gcc -o blink blink.c -lwiringPi */
#include <wiringPi.h>
#include <stdio.h>
int main(void) {
if (wiringPiSetup == -1) { /* numerotation wiringPi */
fprintf(stderr, "wiringPiSetup a echoue (lancer en root ?)\n");
return 1;
}
/* Lancer d'abord `gpio readall` et choisir une broche programmable
du header principal. Ne PAS deviner depuis une table Raspberry Pi. */
const int LED = 0;
pinMode(LED, OUTPUT);
for (;;) {
digitalWrite(LED, HIGH); delay(150);
digitalWrite(LED, LOW); delay(150);
}
}
Compile then run: gcc -o blink blink.c -lwiringPi && sudo ./blink.
Expected verification
The LED blinks approximately 3 times per second (150 ms on, 150 ms off). gpio readall shows the selected pin in OUTPUT mode and alternating between state 1/0.
Common errors
- Forgetting
sudo: wiringPi requires privileged access, sowiringPiSetupreturns -1. - Using a Raspberry Pi pinout table: the Hardkernel fork (
github.com/hardkernel/wiringPi) has its own ODROID tables, always usegpio readall. - Applying 5 V to a pin: the IOs have no overvoltage protection, the board may be destroyed.
- Wrong resistor: without 330 Ω, the LED burns out (or draws too much current).
Other tutorials for this board
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash