openmv4 lcd和舵机怎么同时控制
-
单独使用LCD和单独使用舵机都能动,但是一起的时候舵机就动不了了,该怎么办呢?
THRESHOLD = (86, 100, -16, 8, -23, 23) #线路阈值 import sensor, image, time,lcd from pyb import Servo from pid import PID rho_pid = PID(p=0.4, i=0) #截距 theta_pid = PID(p=0.001, i=0) #斜率 s1 = Servo(1) # P7 def run(_angle,_range,_sleep): #角度,幅度,间隔延时 s1.angle(_angle+_range) #角度,转到该角度的时间 time.sleep(_sleep) s1.angle(_angle-_range) time.sleep(_sleep) sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) # 80x60 (4,800 pixels) - O(N^2) max = 2,3040,000. #sensor.set_windowing([0,20,80,40]) sensor.skip_frames(time = 2000) # WARNING: If you use QQVGA it may take seconds clock = time.clock() # to process a frame sometimes. lcd.init() while(True): clock.tick() #img = sensor.snapshot() img = sensor.snapshot() line = img.get_regression([(100,100,0,0,0,0)], robust = True) if (line): rho_err = abs(line.rho())-img.width()/2 if line.theta()>90: theta_err = line.theta()-180 else: theta_err = line.theta() img.draw_line(line.line(), color = 127) print(rho_err,line.magnitude(),theta_err) #lcd.display(sensor.snapshot()) lcd.display(img.draw_line(line.line(),color=127)) if line.magnitude()>0: #if -40<b_err<40 and -30<t_err<30: rho_output = rho_pid.get_pid(rho_err,1) theta_output = theta_pid.get_pid(theta_err,1) output = rho_output+theta_output #output=output*3 if theta_err>70: #限制摆动角度 theta_err=70 if theta_err<-70: theta_err=-70 run(theta_err,15,180) #角度,幅度,间隔延时 pass
-
引脚冲突,需要舵机扩展板。
https://singtown.com/product/49898/openmv-servo-shield/
-
扩展板如何使用呢?
-
链接里面有使用视频。