🛠 Faire clignoter une LED via le GPIO
Objectives
Blink an external LED from an ODROID-C2 GPIO pin using Hardkernel's wiringPi port (the wiring-odroid package), using the physical pin numbering of the J2 connector — the safest mode on a non-Raspberry Pi board.
Hardware
- ODROID-C2 (Amlogic S905, 2 GB) powered by 5 V / 2 A (2.5x0.8 mm jack preferred)
- Armbian, Arch Linux ARM, or DietPi image
- LED + 330 ohm resistor, breadboard, jumper wires
- Wiring: physical pin 7 (GPIO output) -> resistor -> LED -> GND; 3.3 V logic only across the entire J2 connector
- wiring-odroid package (confirmed on Arch Linux ARM; on vendor images, the wiringPi library is preinstalled)
Complete code
/* blink.c — compiler sur la carte : gcc blink.c -lwiringPi -o blink */
#include <wiringPi.h>
#include <stdio.h>
#define LED 7 /* broche physique 7 du connecteur J2 */
int main(void) {
if (wiringPiSetupPhys == -1) { perror("wiringPiSetupPhys"); return 1; }
pinMode(LED, OUTPUT);
for (;;) {
digitalWrite(LED, HIGH);
delay(500);
digitalWrite(LED, LOW);
delay(500);
}
}
Expected verification
After sudo ./blink, the LED blinks with a one-second period. The user blue LED (c2:blue:alive in mainline, blue:heartbeat on vendor images) continues to blink in a heartbeat pattern: it serves as an independent system indicator. >
Common errors
- Forgetting the resistor: the GPIOs are 3.3 V and the current per pin is limited (wiki value not reconfirmed).
- Using the default wiringPi numbering (Pi-like BCM mode) instead of
wiringPiSetupPhys: the indices do not match the ODROID-C2. - Missing wiring-odroid package on mainline Armbian: in this case, control the blue LED via
/sys/class/leds/*blue*/brightness, or install wiring-odroid on Arch Linux ARM. - Undersized power supply: a micro-USB phone charger causes reboots (brown-out).
Other tutorials for this board
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash