// Motor 1
int en1 = 27;
int step1 = 14;
int dir1 = 12;
// Motor 2
int en2 = 0;
int step2 = 2;
int dir2 = 15;
int a = 0;
unsigned long startTime = 0;

void setup() {
  Serial.begin(9600);
  pinMode(en1, OUTPUT);
  pinMode(step1, OUTPUT);
  pinMode(dir1, OUTPUT);
  pinMode(en2, OUTPUT);
  pinMode(step2, OUTPUT);
  pinMode(dir2, OUTPUT);
  digitalWrite(en1, LOW);
  digitalWrite(en2, LOW);
}

void loop() {
  digitalWrite(dir1, HIGH);
  digitalWrite(dir2, HIGH);
  
  if (a == 0) {
    for (int i = 0; i < 22; i++) {
      Serial.println(1800 - 50 * i);
      motor(1800 - 50 * i);
    }
    
  }
  a += 1;
  Serial.println(a);
  startTime =millis();
  while (a > 0) {
    motor(700);
    if(millis() - startTime > 12000){
      break;
    }
  }
  delay(10000);
}

void motor(int speed) {
  // speed range 400->1000
  for (int x = 0; x < 200; x++) {
    digitalWrite(step1, HIGH);
    digitalWrite(step2, HIGH);
    delayMicroseconds(speed);
    digitalWrite(step1, LOW);
    digitalWrite(step2, LOW);
    delayMicroseconds(speed);
  }
}
A4988
A4988