Here is a demo code that I wrote a while back that may be close to what you want to do. It uses an array of positions and an array of speeds. The motor will go to each position in sequence at the speed in the array. Use whatever parts that you need.
#include <AccelStepper.h>
const unsigned int NUM_STEPS = 6;
unsigned int xArray[NUM_STEPS] = {0, 900, 650, 400, 650, 100};
unsigned int xSpeeds[NUM_STEPS] = {200, 2000, 200, 100, 400, 50};
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)
{
delay(250);
Serial.println(index);
x_stepper.moveTo(xArray[index]);
x_stepper.setMaxSpeed(xSpeeds[index]);
index++;
if (index >= NUM_STEPS)
{
index = 0;
}
}
}