Datasheet
Create the stepper motor object
Request the Stepper motor from the Adafruit_MotorShield:
...with getStepper(steps, stepper#) .
Steps indicates how many steps per revolution the motor has. A 7.5 degree/step motor has 360/7.5 = 48 steps.
Stepper# is which port it is connected to. If you're using M1 and M2, its port 1. If you're using M3 and M4 indicate port 2
Set default speed
Set the speed of the motor using setSpeed(rpm) where rpm is how many revolutions per minute you want the stepper
to turn.
Run the motor
Then every time you want the motor to move, call the step(#steps, direction, steptype) procedure. #steps is how many
steps you'd like it to take. direction is either FORWARD or BACKWARD and the step type is SINGLE, DOUBLE,
INTERLEAVE or MICROSTEP.
"Single" means single-coil activation
"Double" means 2 coils are activated at once (for higher torque)
"Interleave" means that it alternates between single and double to get twice the resolution (but of course its half
the speed).
"Microstepping" is a method where the coils are PWM'd to create smooth motion between steps.
Theres tons of information about the pros and cons of these different stepping methods in the resources page.
You can use whichever stepping method you want, changing it "on the fly" to as you may want minimum power, more
torque, or more precision.
By default, the motor will 'hold' the position after its done stepping. If you want to release all the coils, so that it can
spin freely, call release()
The stepping commands are 'blocking' and will return once the steps have finished.
Because the stepping commands 'block' - you have to instruct the Stepper motors each time you want them to move. If
you want to have more of a 'background task' stepper control, check out AccelStepper library (install similarly to how
you did with Adafruit_MotorShield) which has some examples for controlling three steppers simultaneously with
varying acceleration
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);
© Adafruit Industries https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino Page 33 of 43