美文网首页
云台驱动程序

云台驱动程序

作者: Janeshurmin | 来源:发表于2019-11-06 17:33 被阅读0次
    import RPi.GPIO as GPIO
    import time
    
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(18, GPIO.OUT)
    GPIO.setup(23, GPIO.OUT)
    
    servo1 = GPIO.PWM(18, 50)
    servo1.start(0)
    servo2 = GPIO.PWM(23, 50)
    servo2.start(0)
    
    try:
        while True:
            for dc in range(-5,60,5):
                  i = 7.5+dc*10/180
                  servo1.ChangeDutyCycle(i)
                  servo2.ChangeDutyCycle(i)
                  print(i)
                  time.sleep(0.5)
            for dc in range(55,-10,-5):
                  i = 7.5+dc*10/180
                  servo1.ChangeDutyCycle(i)
                  servo2.ChangeDutyCycle(i)
                print(i)
                time.sleep(0.5)
    except KeyboardInterrupt:
            pass
    
    servo1.stop()
    servo2.stop()
    GPIO.cleanup()
    

    相关文章

      网友评论

          本文标题:云台驱动程序

          本文链接:https://www.haomeiwen.com/subject/bayevctx.html