#include // Include the AccelStepper Library // Define step constant #define HALFSTEP 8 // Creates an instance // Pins entered in sequence 1-3-2-4 for proper step sequencing AccelStepper myStepper(HALFSTEP, 8, 10, 9, 11); void setup() { // set the maximum speed, acceleration factor, // initial speed and the target position myStepper.setMaxSpeed(500.0); //about the max for 28BYJ-48 myStepper.setAcceleration(1); myStepper.setSpeed(5); myStepper.moveTo(1000); } void loop() { // Change direction once the motor reaches target position if (myStepper.distanceToGo() == 0) //how far the motor needs to travel myStepper.moveTo(-myStepper.currentPosition()); //target position // Move the motor one step myStepper.run(); }