const int dir = 5;
const int step = 6;
bool handler = 0;

void setup() {
 pinMode(5, 1);
 pinMode(6, 1);
}

void loop() {
  digitalWrite(dir, 1);

  if (handler == 0){
    for (int x=0; x < 52; x++){
      digitalWrite(step, 1);
      delay(25);
      digitalWrite(step, 0);
      delay(25);
      handler = 1;
    }
  }else if(handler == 1){
    for (int x=0; x < 50; x++){
      digitalWrite(step, 1);
      delay(25);
      digitalWrite(step, 0);
      delay(25);
    }
  }
  delay(3000);

  for (int x=0; x < 50; x++){
    digitalWrite(step, 1);
    delay(25);
    digitalWrite(step, 0);
    delay(25);
  }
  delay(3000);

  digitalWrite(dir, 0);

  for (int x=0; x < 100 ; x++){
    digitalWrite(step, 1);
    delay(25);
    digitalWrite(step, 0);
    delay(25);
  }
  delay(3000);

  for (int x=0; x < 100 ; x++){
    digitalWrite(step, 1);
    delay(25);
    digitalWrite(step, 0);
    delay(25);
  }
  delay(3000);
}
A4988