Basic Usage

You can create multiple AccelStepper objects, giving a unique name to each motor.
AccelStepper can manage any number of motors, as long as you repetitively call
their "run" functions.

Defining & Configuring Motors

AccelStepper mystepper(1, pinStep, pinDirection);

A stepper motor controlled by a dedicated driver board.

AccelStepper mystepper(2, pinA, pinB);

A bipolar stepper motor controlled by an H-Bridge circuit.

AccelStepper mystepper(4, pinA1, pinA2, pinB1, pinB2);

A unipolar stepper motor, controlled by 4 transistors.

mystepper.setMaxSpeed(stepsPerSecond);

Sets the maximum speed. The default is very slow, so this must be configured.
When controlled by setting position, the stepper will accelerate to move at this
maximum speed, and decelerate as it reaches the destination.

mystepper.setAcceleration(stepsPerSecondSquared);

Sets the acceleration to be used, in steps per second per second.

Position Based Control

mystepper.moveTo(targetPosition);

Move the motor to a new absolute position.
This returns immediately. Actual movement is caused by the run() function.

mystepper.move(distance);

Move the motor (either positive or negative) relative to its current position.
This returns immediately. Actual movement is caused by the run() function.

mystepper.currentPosition();

Read the motor's current absolution position.

mystepper.distanceToGo();

Read the distance the motor is from its destination position. This can be
used to check if the motor has reached its final position.

mystepper.run();

Update the motor. This must be called repetitively to make the motor move.

mystepper.runToPosition();

Update the motor, and wait for it to reach its destination. This function
does not return until the motor is stopped, so it is only useful if no other
motors are moving.

Speed Based Control

mystepper.setSpeed(stepsPerSecond);

Set the speed, in steps per second. This function returns immediately. Actual
motion is caused by called runSpeed().

mystepper.runSpeed();

Update the motor. This must be called repetitively to make the motor move.