Yes, that's how it is now ( if you change 10->0 )
But you must do that in loop():
// Include AccelStepper Library
#include <AccelStepper.h>
//Define motor pin connections
const int dirPin = 2;
const int stepPin = 3;
const long targetPos = 5000;
// Define motor interface type
#define motorInterfaceType 1
// Creates an instance
AccelStepper myStepper(motorInterfaceType, stepPin, dirPin);
void setup() {
// set the maximum speed, acceleration factor,
// initial speed and the target position
myStepper.setMaxSpeed(350);
myStepper.setAcceleration(50);
// myStepper.setSpeed(250); // This is useless, as .run() only follows maxSpeed!
myStepper.moveTo(5000);
}
void loop() {
// Change direction once the motor reaches target position
if (myStepper.distanceToGo() == 0) {
if (myStepper.currentPosition() == 0) {
myStepper.moveTo(targetPos);
} else {
myStepper.moveTo(0);
}
}
// Move the motor one step
myStepper.run();
}