I've written a short script to run the wheels in each direction.
It works, though the diagonal drive seems to struggle a little with the carpet?
import time
from adafruit_motorkit import MotorKit
kit = MotorKit()
def all_ahead():
kit.motor1.throttle = -1.0
kit.motor2.throttle = 1.0
kit.motor3.throttle = -1.0
kit.motor4.throttle = 1.0
print("All Ahead")
def all_reverse():
kit.motor1.throttle = 1.0
kit.motor2.throttle = -1.0
kit.motor3.throttle = 1.0
kit.motor4.throttle = -1.0
print("All Reverse")
def all_stop():
kit.motor1.throttle = 0
kit.motor2.throttle = 0
kit.motor3.throttle = 0
kit.motor4.throttle = 0
print("All Stop")
def turn_left():
kit.motor1.throttle = -1.0
kit.motor2.throttle = 1.0
kit.motor3.throttle = 0
kit.motor4.throttle = 0
print("Turn Left")
def crab_right():
kit.motor1.throttle = 1.0
kit.motor2.throttle = 1.0
kit.motor3.throttle = -1.0
kit.motor4.throttle = -1.0
print("Crab Right")
def spin_right():
kit.motor1.throttle = 1.0
kit.motor2.throttle = -1.0
kit.motor3.throttle = -1.0
kit.motor4.throttle = 1.0
print("Spin Right")
def spin_left():
kit.motor1.throttle = -1.0
kit.motor2.throttle = 1.0
kit.motor3.throttle = 1.0
kit.motor4.throttle = -1.0
print("Spin Left")
def diag_right():
kit.motor1.throttle = 0
kit.motor2.throttle = 1.0
kit.motor3.throttle = -1.0
kit.motor4.throttle = 0
print("Diag Right")
def diag_left():
kit.motor1.throttle = -1.0
kit.motor2.throttle = 0
kit.motor3.throttle = 0
kit.motor4.throttle = 1.0
print("Diag Left")
try:
while 1:
all_ahead()
time.sleep(2)
all_stop()
all_reverse()
time.sleep(2)
all_stop()
crab_left()
time.sleep(2)
all_stop()
crab_right()
time.sleep(2)
all_stop()
turn_right()
time.sleep(2)
all_stop()
turn_left()
time.sleep(2)
all_stop()
spin_right()
time.sleep(2)
all_stop()
spin_left()
time.sleep(2)
all_stop()
diag_right()
time.sleep(2)
all_stop()
diag_left()
time.sleep(2)
all_stop()
except KeyboardInterrupt:
all_stop()
pass
Comments
Post a Comment