I adapted a code that I wrote a while back to accomplish your goal.
#include <AccelStepper.h>
const unsigned int NUM_STEPS = 2;
unsigned int xArray[NUM_STEPS] = {3000, 2500};
unsigned int xSpeeds[NUM_STEPS] = {500, 500};
const byte enablePin = 8;
AccelStepper x_stepper(AccelStepper::DRIVER, 2, 5);
void setup()
{
Serial.begin(115200);
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, LOW);
x_stepper.setAcceleration(2000);
x_stepper.setMaxSpeed(200);
x_stepper.setSpeed(200);
x_stepper.setCurrentPosition(0);
}
void loop()
{
static unsigned int index = 0;
if (x_stepper.run() == 0)
{
Serial.println(index);
x_stepper.moveTo(xArray[index]);
x_stepper.setMaxSpeed(xSpeeds[index]);
index++;
if (index > NUM_STEPS)
{
while(1); // stop forever
}
}
}