티스토리 뷰

OS/Raspberry Pi

Wiring Pi

파란크리스마스 2016. 3. 12. 23:33
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

실행 결과

댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함