SG90 라즈베리파이 연결
색 | 핀 |
오렌지 | GPIO18 (wiringPi에서 1번핀) |
레드 | 5V |
브라운 | GND |
예제 파일
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 32 33 34 | #include <stdio.h> #include <wiringPi.h> #include <stdlib.h> #include <softPwm.h> void lock(); void unLock(); int pin = 1; int main(void) { if(wiringPiSetup()==-1) exit(1); pinMode(pin ,OUTPUT); digitalWrite(pin,LOW); softPwmCreate(pin,0,200); printf("Test Servo motor\n"); int i=0; while(1){ scanf("%d",&i); if(i) lock(); else unLock(); } return 0; } void lock(){ softPwmWrite(pin,14); } void unLock(){ softPwmWrite(pin,22); } | cs |
결과 사진
0이나 1 입력시
'프로그래밍 > 라즈베리파이' 카테고리의 다른 글
(라즈베리파이) 아두이노와 통신 - WiringPi (0) | 2018.08.31 |
---|---|
(라즈베리파이 3) gpio를 이용한 Serial 통신 (4) (0) | 2018.08.31 |
(라즈베리파이) VNC Viewer를 이용한 원격 GUI (0) | 2016.07.10 |
(라즈베리파이)wiringPi 설치 및 정보 (0) | 2016.07.10 |
(라즈베리파이 3) gpio를 이용한 Serial 통신 (3) (0) | 2016.07.10 |