8from machine
import UART, Pin
9port = UART(1, 115200, tx=Pin(4), rx=Pin(5), timeout=100)
11def set_max_acceleration(motor, accel):
13 0x9C, motor, 10, accel & 0x7F, (accel >> 7) & 0x7F,
14 0x9C, motor, 12, accel & 0x7F, (accel >> 7) & 0x7F]))
16def set_max_deceleration(motor, decel):
18 0x9C, motor, 14, decel & 0x7F, (decel >> 7) & 0x7F,
19 0x9C, motor, 16, decel & 0x7F, (decel >> 7) & 0x7F]))
21def set_speed(motor, speed):
22 port.write(bytes([0xD1, motor, speed & 0x7F, (speed >> 7) & 0x7F]))
29 0x8B, 0x04, 0x7B, 0x43,
50set_max_acceleration(1, 140)
51set_max_deceleration(1, 300)
54set_max_acceleration(2, 200)
55set_max_deceleration(2, 300)
58 if time.ticks_ms() & 2048: