L298NHBridge.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:raspberry 作者: ykevin 项目源码 文件源码
def __init__(self, left_pin1, left_pin2, right_pin1, right_pin2, leftpwm_pin, rightpwm_pin):
        io.setmode(io.BCM)
        # Constant values
        self.PWM_MAX = 100
        # Here we configure the GPIO settings for the left and right motors spinning direction. 
        # It defines the four GPIO pins used as input on the L298 H-Bridge to set the motor mode (forward, reverse and stopp).
        self.leftmotor_in1_pin = left_pin1
        self.leftmotor_in2_pin = left_pin2
        self.rightmotor_in1_pin = right_pin1
        self.rightmotor_in2_pin = right_pin2
        self.leftmotorpwm_pin = leftpwm_pin
        self.rightmotorpwm_pin = rightpwm_pin
        self.SetupGPIO()
        self.leftmotorpwm = io.PWM(self.leftmotorpwm_pin,100)
        self.rightmotorpwm = io.PWM(self.rightmotorpwm_pin,100)
        self.InitPWM()
        # Disable warning from GPIO
        io.setwarnings(False)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号