🛠 Allumer une LED via le GPIO

Hardkernel ODROID-XU4 (Samsung Exynos5422) · debutant · Schéma : IMG-odroid-xu4-debutant-1-odroidxu4-led-gpio.svg — L'ODROID-XU4 avec son header 30 broches, une LED et sa résistance 330 Ω branchées sur une broche GPIO, alimentation 5 V/4 A

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

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

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials