// Include the AccelStepper library:
#include <AccelStepper.h>

// Define stepper motor connections and motor interface type. Motor interface type must be set to 1 when using a driver:
#define dirPin 10
#define stepPin 9
#define motorInterfaceType 1

#define dirPin1 12
#define stepPin1 11
#define motorInterfaceType1 1

// Create a new instance of the AccelStepper class:
AccelStepper stepper = AccelStepper(motorInterfaceType, stepPin, dirPin);
AccelStepper stepper1 = AccelStepper(motorInterfaceType1, stepPin1, dirPin1);

void setup() {
  // Set the maximum speed in steps per second:
  stepper.setMaxSpeed(1500);
  stepper1.setMaxSpeed(500);
}

void loop() { 
  // Set the current position to 0:
  stepper.setCurrentPosition(0);
  stepper1.setCurrentPosition(0);

  stepper.setSpeed(1400);
  stepper.runSpeed();
  // Run the motor forward at 200 steps/second until the motor reaches 400 steps (2 revolutions):
  while(stepper1.currentPosition() != 400)
  {
    stepper1.setSpeed(300);
    stepper1.runSpeed();
  }

  delay(1000);

  // Reset the position to 0:
  stepper1.setCurrentPosition(0);
  stepper.setCurrentPosition(0);
}




  /*
  // Run the motor backwards at 600 steps/second until the motor reaches -200 steps (1 revolution):
  while(stepper.currentPosition() != -200) 
  {
    stepper.setSpeed(-600);
    stepper.runSpeed();
  }

  delay(1000);

  // Reset the position to 0:
  stepper.setCurrentPosition(0);

  // Run the motor forward at 400 steps/second until the motor reaches 600 steps (3 revolutions):
  while(stepper.currentPosition() != 600)
  {
    stepper.setSpeed(400);
    stepper.runSpeed();
  }

  delay(3000);
}
*/
A4988
A4988