def __init__(self, left, right, enable_pin):
"""Constructor.
Args:
forward_pin (int): GPIO pin connected to motor's forward pin.
backward_pin (int): GPIO pin connected to motor's backward pin.
enable_pin (int): GPIO pin connected to motor's enable pin
"""
# store pins
self.left_pin = left
self.right_pin = right
self.pwm_pin = enable_pin
self.turn_direction = 0.0; # [-1, 1]
GPIO.setup( [self.left_pin, self.right_pin, self.pwm_pin], GPIO.OUT, initial=False)
# frequency (Hz) second parameter
self.pwm = GPIO.PWM(self.pwm_pin, 100)
self.pwm.start(0.0)
# initial direction: 0.0
# self.change_dir(True);
评论列表
文章目录