help with coding for a stepper motor

Photo-Tom:
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?

Try a lower speed and acceleration. That should deal with missing steps.

The way you have written you code will work - but it is not the style in which AccelStepper is normally used - because the Arduino can do nothing until the WHILE completes.

If you build a more complex program using the same style the blocking will probably become a problem.

...R