AccelStepper.h, motors will not move.

mbr29:
Thank you for the code sample, I'll try it when I get a chance. However, if I add a second motor, say, stepper2, and I want it to do the same thing as stepper1, but not simultaneously, where it only turns after stepper1 is finished, wouldn't a loop like that force them to move at the same time?

First off, the purpose of my code was ONLY to ensure that you can get one motor to work with code that has some resemblance to your own code.

Second, the easiest way to answer many Arduino questions is to try something and see what happens. The Arduino system is great for learning by doing.

Third, there is a mistake in my code. I had (incorrectly) thought that runSpeedToPosition() would complete its move before moving on to the next line of code - i.e. block the Arduino until it finishes. However I don't think it does. The blocking functions are runToPosition() and runToNewPosition() and both of them use acceleration. Consequently you have two choices {A} replace runSpeedToPosition() with runToPosition() in the code in Reply #3 - in which case you will get the sequential behaviour that you want. OR {B} you need to use code something like this

char stepper1State = 'W'; // Paused Waiting Running Done
char stepper2State = 'P';



void loop() {
    if (stepper1State == 'W') {
        stepper1State = 'R';
        stepper1.move(steps);
        stepper1.setSpeed(1000);
    }
    else {
        if (stepper1.distanceToGo() ==  0) {
            stepper1State = 'D';
            stepper2State = 'W';
            delay(2000); // if you want a delay between movements
        }
    }
    
    if (stepper2State == 'W') {
        stepper2State = 'R';
        stepper1.move(steps);
        stepper1.setSpeed(1000);
    }
    else {
        if (stepper1.distanceToGo() ==  0)
            stepper2State = 'D';
            stepper1State = 'W'; // if you want the sequence to repeat
            delay(2000); // if you want a delay between movements
        }



    stepper1.runSpeedToPosition();
    stepper2.runSpeedToPosition();
}

...R