from adafruit_crickit import crickit class Drivetrain: #constructor def __init__(self,left_rev,right_rev): self.speed_left = 0 self.speed_right = 0 self.left_rev = left_rev self.right_rev = right_rev self.left_motor = crickit.dc_motor_1 self.right_motor = crickit.dc_motor_2 #methods (functions) def set_speed(self,speed): if self.left_rev == True: self.speed_left = speed * -1 else: self.speed_left = speed if self.right_rev == True: self.speed_right = speed * -1 else: self.speed_right = speed def forward(self): self.left_motor.throttle = self.speed_left self.right_motor.throttle = self.speed_right def stop(self): self.left_motor.throttle = 0 self.right_motor.throttle = 0 def backward(self): self.left_motor.throttle = -self.speed_left self.right_motor.throttle = -self.speed_right def left(self): self.left_motor.throttle = -self.speed_left self.right_motor.throttle = self.speed_right def right(self): self.left_motor.throttle = self.speed_left self.right_motor.throttle = -self.speed_right