help with coding for a stepper motor

Brilliant,

thanks Robin2,

I altered the code to this:

AccelStepper stepper (1,3,2); // name of stepper motor (1 = driver, pin 3 = step, pin 2 = direction)


void setup() {
 
    stepper.setMaxSpeed(1000);
    stepper.setAcceleration(200);
}

void loop()
{
  stepper.moveTo(100);  // 
  while (stepper.distanceToGo() != 0) 
  {  stepper.run(); }

  stepper.moveTo(0);  // 
  while (stepper.distanceToGo() != 0) 
  {  stepper.run(); }
}

As it runs, the stepper doesn't always move back to its original starting position. Would this be because its missing steps? is there any way of limiting this?