Commit 1cf7ec65 authored by jiajunjie's avatar jiajunjie

update

parent 458d56a1
import time
from ctypes import *
import ctypes
import cv2
so = ctypes.cdll.LoadLibrary
pwm = so("./libPCA9685.so")
def set_servo_angle(channel, angle):
date=4096*((angle*11)+500)/20000
pwm.setPWM(channel, int(date))
def get_servo_angle(channel):
date=pwm.getPWM(channel+1)
angle=(20000*date - 500*11)/(4096*11) -45
print(str(channel) +':'+ str(int(angle)))
# Set frequency to 50hz, good for servos.
pwm.setPWMFreq(50)
print('Moving servo on channel x, press Ctrl-C to quit...')
while True:
# Move servo on channel O between extremes.
get_servo_angle(1)
get_servo_angle(2)
channel=int(input('pleas input channel:'))
angle=int(input('pleas input angle:'))
set_servo_angle(channel, angle)
time.sleep(1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment