🛠 Faire clignoter une LED via le GPIO

Hardkernel ODROID-C2 (Amlogic S905) · debutant · Schéma : IMG-odroid-c2-debutant-1-odroidc2-led-gpio.svg — LED et résistance 330 ohms branchées sur le connecteur J2 de l'ODROID-C2

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

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

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials