2014年10月15日 星期三

The Raspberry Pi Contorl Servo Motors

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)

a=GPIO.PWM(4,50)
a.start(5)

b=GPIO.PWM(18,50)
b.start(5)

c=GPIO.PWM(22,50)
c.start(5)

while True:
        a.ChangeDutyCycle(2.5)
        c.ChangeDutyCycle(2.5)
        print'5'
        time.sleep(2)
        a.ChangeDutyCycle(7.5)
        print'10'
        time.sleep(2)
        a.ChangeDutyCycle(12)
        print'15'
        time.sleep(2)

沒有留言:

張貼留言