import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12, GPIO.OUT)
p = GPIO.PWM(12, 50)
p.start(7.5)
try:
while True:
p.ChangeDutyCycle(7.5) # turn towards 90 degree
time.sleep(1) # sleep 1 second
p.ChangeDutyCycle(2.5) # turn towards 0 degree
time.sleep(1) # sleep 1 second
p.ChangeDutyCycle(12.5) # turn towards 180 degree
time.sleep(1) # sleep 1 second
except KeyboardInterrupt:
p.stop()
GPIO.cleanup()
3V - Red
Ground - Green
Output GPIO18 = 12 - Yellow
아두이노는 5V 에 입력을 하는데, 라즈베리파이는 3V에 연결을 해야함, 5V연결시에 라즈베리파에 보드에 데미지를 줄 수 있음
'Computer > Linux' 카테고리의 다른 글
Agenti - web admin (0) | 2019.05.03 |
---|---|
Xiaomi Mijia Hygrothermo V2 read data from Python3 샤오미 온습도계V2 파이썬으로 읽기 (0) | 2019.02.07 |
Wifi password setting/change (0) | 2019.02.07 |
라즈베리파이 블루투스 활용 (0) | 2019.02.07 |
WAVESHARE e-paper display (0) | 2019.02.07 |
Transmission (0) | 2019.02.07 |
Wifi access point 2개 저장하기 (0) | 2019.02.07 |
라즈베리파이 - I2C 1602 LCD module (0) | 2019.02.07 |