728x90
출처 : Download & Install - WiringPi
라즈베리파이 GPIO 강좌 : 04. Output 테스트 (LED 출력, C언어)
라즈베리파이 업데이트, 업그레이드
$ sudo apt-get update $ sudo apt-get upgrade
소스관리툴 git 다운로드
$ sudo apt-get install git-core
wiringPi 소스 다운로드
git clone git://git.drogon.net/wiringPi
wiringPi 컴파일
$ ./build
wiringPi 설치확인
$ gpio -v gpio readall gpio version: 2.32 Copyright (c) 2012-2015 Gordon Henderson This is free software with ABSOLUTELY NO WARRANTY. For details type: gpio -warranty Raspberry Pi Details: Type: Pi 2, Revision: 01, Memory: 1024MB, Maker: Sony * Device tree is enabled. * This Raspberry Pi supports user-level GPIO access. -> See the man-page for more details -> ie. export WIRINGPI_GPIOMEM=1
LDE 제어하기
소스 작성
$ vi led.c
#include#include #define LED1 28 // BCM_GPIO 20 #define LED2 29 // BCM_GPIO 21 int main (void) { if (wiringPiSetup () == -1) return 1 ; pinMode (LED1, OUTPUT) ; pinMode (LED2, OUTPUT) ; for (;;) { digitalWrite (LED1, 1) ; // On digitalWrite (LED2, 1) ; // On delay (1000) ; // ms digitalWrite (LED1, 0) ; // Off digitalWrite (LED2, 0) ; // Off delay (1000) ; } return 0 ; }
컴파일
$ gcc -o led led.c -lwiringPi
실행
$ sudo ./led
실행 결과
728x90