电机和舵机是否能同时驱动?
-
THRESHOLD = (40, 100, -128, 127, -128, 127) # Grayscale threshold for dark things... import sensor, image, time from pyb import LED, Servo from tb6612 import Motor servo3 = Servo(3) servo3.angle(0) m1 = Motor(1) # motor 1: A0 and A1 #m2 = Motor(2) # motor 2: B0 and B1 LED(1).on() LED(2).on() LED(3).on() sensor.reset() sensor.set_vflip(True) sensor.set_hmirror(True) sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQQVGA) # 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. while(True): clock.tick() m1.set_speed(10) # Forward #m2.set_speed(10) # Forward img = sensor.snapshot().binary([THRESHOLD]) line = img.get_regression([(100,100)], 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) if line.magnitude()>8: servo3.angle(0+theta_err)
-
不能同时使用,引脚冲突。
-
舵机用p9 电机用p7 p8也不行吗?
-
那可以,但是电机的pwm定时器要改,不能用4
-
比如说? 我改了好像有报错,只需要实现驱动一个功能
-
你用的什么OpenMV硬件?
-
@kidswong999 openmv4 h7
-
https://github.com/openmv/openmv/blob/master/scripts/libraries/tb6612.py
得把这里面的time4都改成其他的,然后把tb6612.py放到sd卡里。