User Manual

CircuitPython stepper motor control is pretty simple - you can access the motor port for stepper control via the
crickit.stepper_motor object (it's an adafruit_motor.stepper type object (https://adafru.it/BNE)).
With that object, you can call onestep() to step once, with the direction and stepping style included. The default
direction is FORWARD and the default style is SINGLE .
Note that 'forward' and 'backward' are, like DC motors, dependent on your wiring and coil order so you can flip around
the coil wiring if you want to change what direction 'forward' and 'backward' means.
Putting time.sleep() 's between steps will let you slow down the stepper motor, however most steppers are geared so
you may not want any delays.
Uni-Polar Only Drive Port
The Drive port can also control steppers although it can only do uni-polar! Don't try connecting a 4-wire bi-polar
stepper, it won't work at all.
import time
from adafruit_crickit import crickit
from adafruit_motor import stepper
print("Bi-Polar or Uni-Polar Stepper motor demo!")
# make stepper motor a variable to make code shorter to type!
stepper_motor = crickit.stepper_motor
# increase to slow down, decrease to speed up!
INTERSTEP_DELAY = 0.01
while True:
print("Single step")
for i in range(200):
stepper_motor.onestep(direction=stepper.FORWARD)
time.sleep(INTERSTEP_DELAY)
for i in range(200):
stepper_motor.onestep(direction=stepper.BACKWARD)
time.sleep(INTERSTEP_DELAY)
print("Double step")
for i in range(200):
stepper_motor.onestep(direction=stepper.FORWARD, style=stepper.DOUBLE)
time.sleep(INTERSTEP_DELAY)
for i in range(200):
stepper_motor.onestep(direction=stepper.BACKWARD, style=stepper.DOUBLE)
time.sleep(INTERSTEP_DELAY)
print("Interleave step")
for i in range(200):
stepper_motor.onestep(direction=stepper.FORWARD, style=stepper.INTERLEAVE)
time.sleep(INTERSTEP_DELAY)
for i in range(200):
stepper_motor.onestep(direction=stepper.BACKWARD, style=stepper.INTERLEAVE)
time.sleep(INTERSTEP_DELAY)
© Adafruit Industries
https://learn.adafruit.com/adafruit-crickit-creative-robotic-interactive-
construction-kit
Page 103 of 201