SlideShare a Scribd company logo
1 of 15
Download to read offline
라즈베리파이GPIO활용
임광규
뭉클-라즈베리파이로개발환경구축하기 1
WhereisGPIO?
뭉클-라즈베리파이로개발환경구축하기 2
GPIO
라즈베리파이의GPIO는2버전을기준으로26
개의IO를지원하였으나지금은40개의IO를
지원합니다.
라즈베리파이는단순디지털입출력뿐만아니
라,직렬시리얼통신(UART),I2C(Inter-
IntegratedCircuit),SPI(Serial
PeripheralInterface),PWM(Pulse
WidthModulation)등다양한입출력을제공
합니다.
이미지출처:SparkFun
뭉클-라즈베리파이로개발환경구축하기 3
GPIO
GPIO는GeneralPurposeInput/Output으로,말그대로범용입출력인터페이스입니다.PCB,ICT보드
등다양한전자기판에서내부회로이외외부적으로물리적으로소통할수있는장치로,이를이용해서LED,
ServoMotor등다양한물리적외부장치들에대해서배선하고연결하여제어할수있습니다.
뭉클-라즈베리파이로개발환경구축하기 4
WhatisBCMANDBoard
BCM(Broadcomchip-specificpinnumbers)은핀의번호
BOARD는라즈베리파이보드번호
뭉클-라즈베리파이로개발환경구축하기 5
GPIO확인명령어
$ pinout
뭉클-라즈베리파이로개발환경구축하기 6
GPIO지원언어&Tool
GPIOwithScratch1.4
GPIOwithScratch2
GPIOwithPython
GPIOwithC/C++usingstandardkernelinterfacevialibgpiod
GPIOwithC/C++using3rdpartylibrarypigio
GPIOwithProcessing3
뭉클-라즈베리파이로개발환경구축하기 7
Scratch2설치하기
설치하기전에최신상태로업데이터
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade
$ sudo reboot
Scratch2설치
$ sudo apt-get install scratch2
뭉클-라즈베리파이로개발환경구축하기 8
Scratch2GPIO설정
MoreBlocks>AddanExtension>PiGPIO
뭉클-라즈베리파이로개발환경구축하기 9
SettingGPIO
뭉클-라즈베리파이로개발환경구축하기 10
HelloGPIOwith
Scratch2
1.클릭발생
2.앞으로10px이동
3."야옹"소리를낸다.
4.5회반복
26번Pin전원을켠다.
오른쪽으로15도돈다.
1초쉰다.
왼쪽으로15도돈다
26번Pin전원을끄다
1초쉰다.뭉클-라즈베리파이로개발환경구축하기 11
HelloGPIOwithPython
# -*- coding:utf-8 -*-
import RPi.GPIO as g
import time //GPIO핀을 제어하기 위해 GPIO 라이브러리 가져오기 및 타이머
g.setmode(GPIO.BCM) //GPIO핀이 준비되어 있는지 확인 GPIO.BCM, GPIO.BOARD 둘 중 하나 사용
g.setup(26, GPIO.OUT) //GPIO 26핀 아웃 설정
try:
for i in rang(0, 5):
g.output(26, True)
time.sleep(1)
g.output(26, False)
time.sleep(1)
except KeyboardInterrupt: //인터럽트를 위한 설정 Ctrl + C를 누르면 인터럽트 실행
print('취소')
finally:
g.cleanup() //라즈베리 파이 초기화
뭉클-라즈베리파이로개발환경구축하기 12
GPIOINPUTwithPython
Python에서Input을사용할때값을넣어두지않으면해당입력을확인할때마다랜덤하게1,
0이출력된다.
뭉클-라즈베리파이로개발환경구축하기 13
추가팁
화면캡처방법
터미널에서scrot명령어를이용하면화면을캡처할수있다.
저장된파일의위치는/home/pi이다.
# 전체 화면 캡처
$ scrot
# 마우스를 이용한 선택 영역 캡처
$ scrot -s
# 활성화된 윈도우 캡처
$ scrot -u
뭉클-라즈베리파이로개발환경구축하기 14
참고자료
DOCUMENTATION>USAGE>GPIO
뭉클-라즈베리파이로개발환경구축하기 15

More Related Content

More from Daniel Lim

개발자를 넘어 기술 리더로 가는 길을 읽고
개발자를 넘어 기술 리더로 가는 길을 읽고개발자를 넘어 기술 리더로 가는 길을 읽고
개발자를 넘어 기술 리더로 가는 길을 읽고Daniel Lim
 
스크럼 101
스크럼 101스크럼 101
스크럼 101Daniel Lim
 
nodejs_101.pdf
nodejs_101.pdfnodejs_101.pdf
nodejs_101.pdfDaniel Lim
 
피드백 시스템
피드백 시스템피드백 시스템
피드백 시스템Daniel Lim
 
12.context api
12.context api12.context api
12.context apiDaniel Lim
 
11.react router dom
11.react router dom11.react router dom
11.react router domDaniel Lim
 
9.component style
9.component style9.component style
9.component styleDaniel Lim
 
7.component life cycle
7.component life cycle7.component life cycle
7.component life cycleDaniel Lim
 
6.component repeat
6.component repeat6.component repeat
6.component repeatDaniel Lim
 
4.event handling
4.event handling4.event handling
4.event handlingDaniel Lim
 
3.component 101
3.component 1013.component 101
3.component 101Daniel Lim
 
Swagger? OAS? with NodeJS
Swagger? OAS? with NodeJSSwagger? OAS? with NodeJS
Swagger? OAS? with NodeJSDaniel Lim
 

More from Daniel Lim (20)

개발자를 넘어 기술 리더로 가는 길을 읽고
개발자를 넘어 기술 리더로 가는 길을 읽고개발자를 넘어 기술 리더로 가는 길을 읽고
개발자를 넘어 기술 리더로 가는 길을 읽고
 
스크럼 101
스크럼 101스크럼 101
스크럼 101
 
nodejs_101.pdf
nodejs_101.pdfnodejs_101.pdf
nodejs_101.pdf
 
For You
For YouFor You
For You
 
Nest js 101
Nest js 101Nest js 101
Nest js 101
 
피드백 시스템
피드백 시스템피드백 시스템
피드백 시스템
 
13.code split
13.code split13.code split
13.code split
 
12.context api
12.context api12.context api
12.context api
 
11.react router dom
11.react router dom11.react router dom
11.react router dom
 
9.component style
9.component style9.component style
9.component style
 
7.component life cycle
7.component life cycle7.component life cycle
7.component life cycle
 
8.hooks
8.hooks8.hooks
8.hooks
 
6.component repeat
6.component repeat6.component repeat
6.component repeat
 
4.event handling
4.event handling4.event handling
4.event handling
 
5.ref 101
5.ref 1015.ref 101
5.ref 101
 
3.component 101
3.component 1013.component 101
3.component 101
 
2.jsx 101
2.jsx 1012.jsx 101
2.jsx 101
 
1.react 101
1.react 1011.react 101
1.react 101
 
Swagger? OAS? with NodeJS
Swagger? OAS? with NodeJSSwagger? OAS? with NodeJS
Swagger? OAS? with NodeJS
 
CuKu V1.3
CuKu V1.3CuKu V1.3
CuKu V1.3
 

라즈베리파이 배우기 GPIO 편