Tinker Board : C언어를 이용한 GPIO LED 제어

OS/Tinker Board 2018.09.03 00:55 Posted by 파란크리스마스

출처

led.c

#include <stdio.h>
#include <wiringpi.h>

// #define LED 0 matches with ASUS_GPIO 164! This can be checked with command 'sudo gpio readall'.
#define LED     8

int main (void)
{
         printf ("TB blink\n");

         wiringPiSetup ();
         pinMode (LED, OUTPUT);

         for (;;)
         {
                 printf ("led on\n");
                 digitalWrite (LED, HIGH);
                 delay (500);
                 printf ("led off\n");
                 digitalWrite (LED, LOW);
                 delay (500);
         }
         return 0;
}

컴파일

$ gcc -o led led.c -lwiringPi

실행

$ ./led