ch-10 clean

This commit is contained in:
Danny Staple
2022-03-20 22:31:18 +00:00
parent c632222255
commit b595f3be54
14 changed files with 369 additions and 356 deletions
+5 -3
View File
@@ -29,6 +29,7 @@ def stop():
motor_B1.duty_cycle = 0
motor_B2.duty_cycle = 0
def set_speed(motor, speed):
# Swap motor pins if we reverse the speed
if speed < 0:
@@ -36,15 +37,16 @@ def set_speed(motor, speed):
speed = -speed
else:
direction = motor
speed = min(speed, 1) # limit to 1.0
max_speed = 2**16-1
speed = min(speed, 1) # limit to 1.0
max_speed = 2 ** 16 - 1
direction[0].duty_cycle = int(max_speed * speed)
direction[1].duty_cycle = 0
def set_left(speed):
set_speed(left_motor, speed)
def set_right(speed):
set_speed(right_motor, speed)