想通过openmv识别单线和双线
gu1t
@gu1t
0
声望
8
楼层
1040
资料浏览
0
粉丝
0
关注
gu1t 发布的帖子
-
RE: openmv巡线小车电机驱动用l298n怎么写
from pyb import Pin, Timer inverse_left=False #change it to True to inverse left wheel inverse_right=False #change it to True to inverse right wheel IN1 = Pin('P0', Pin.OUT_PP) IN2 = Pin('P1', Pin.OUT_PP) IN3 = Pin('P2', Pin.OUT_PP) IN4 = Pin('P3', Pin.OUT_PP) IN1.low() IN2.low() IN3.low() IN4.low() ENA = Pin('P7') ENB = Pin('P8') tim = Timer(4, freq=1000) ch1 = tim.channel(1, Timer.PWM, pin=ENA) ch2 = tim.channel(2, Timer.PWM, pin=ENB) ch1.pulse_width_percent(0) ch2.pulse_width_percent(0) def run(left_speed, right_speed): if inverse_left==True: left_speed=(-left_speed) if inverse_right==True: right_speed=(-right_speed) if left_speed < 0: IN1.low() IN2.high() else: IN1.high() IN2.low() ch1.pulse_width_percent(abs(left_speed)) if right_speed < 0: IN3.low() IN4.high() else: IN3.high() IN4.low() ch2.pulse_width_percent(abs(right_speed))
您看一下 这样写对吗
import car while True: car.run(100,100)
-
openmv巡线小车电机驱动用l298n怎么写
教程的是用tb6612fng,我这里有l298n,那么代码和教程的一样吗,需要改吗,还有就是代码有些没看懂,能大概讲一下吗,把主体讲一下,(程序框图),谢谢,嘿嘿。