#include <AccelStepper.h>

//define maximum speed and acceleration time
#define SET_MAX_SPEED 2000
#define SET_ACCELERATION_TIME 1000

//set stepper motor step and direction control pins
AccelStepper stepper(1, 19, 14);

// set stepper motor initial configuration
void setup(){
  stepper.setMaxSpeed(SET_MAX_SPEED); // maximum speed
  stepper.setAcceleration(SET_ACCELERATION_TIME); // acceleration time
  stepper.setCurrentPosition(0);
}

void loop(){
  digitalWrite(14, LOW);
  runStepper(100);
  delay(3000);
  digitalWrite(14, HIGH);
  runStepper(0);
  delay(3000);
}
// run the stepper with target position angle
void runStepper(int TARGET_POSITION) {
  stepper.moveTo(TARGET_POSITION);
  while (stepper.distanceToGo() != 0) {
    stepper.runSpeedToPosition();
    delay(3); // Add a short delay after each step
  }
}
A4988