Stepper Motor Wait before reversing

So I’m wanting to make a stepper motor rotate 800 steps clockwise and then 800 steps counter clockwise after 15 seconds. So move CW 800 steps and then delay(15000) and turn CCW 800 steps… I’ve played with the code trying to get it to do it but it reads the step count first for CW and then CCW and it’s agitating like a washing machine which isn’t the result I was looking for. How would a person separate out the code to make it step 800 CW first and then 800 CCW after a delay?

const int stepPin = 5;
const int dirPin = 2;
const int enPin = 8;
int inPinLeft = 12;
int inPinRight = 11;
int valLeft = 0;
int valRight = 0;
int ledPin = 13;

void setup() {
Serial.begin(9600);
Serial.println(“Booting UP System and checking Stepper Motor Controller”);
// Sets the two pins as Outputs
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
pinMode(enPin,OUTPUT);
digitalWrite(enPin,LOW);
pinMode(inPinLeft, INPUT);
pinMode(inPinRight, INPUT);
Serial.println(“System Ready!”);
delay(500);
}
void loop() {
valLeft = digitalRead(inPinLeft);
valRight = digitalRead(inPinRight);
if(valLeft == HIGH){
digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
// Makes 200 pulses for making one full cycle rotation
for(int x = 0; x < 800; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
delay(15000);
for(int x = 0; x < 800; x++) {
digitalWrite(dirPin,LOW);
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
}
}
delay(1000); // One second delay
if(valRight == HIGH){
digitalWrite(dirPin,LOW); //Changes the rotations direction
// Makes 400 pulses for making two full cycle rotation
for(int x = 0; x < 800; x++) {
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
delay(15000);
for(int x = 0; x < 800; x++) {
digitalWrite(dirPin,HIGH);
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
}
}
delay(1000);
}

Please use the code button </> for code - like this

const int stepPin = 5; 
    const int dirPin = 2; 
    const int enPin = 8;
    int inPinLeft = 12;
    int inPinRight = 11;
    int valLeft = 0;
    int valRight = 0;
    int ledPin = 13;

    void setup() {
      Serial.begin(9600);
      Serial.println("Booting UP System and checking Stepper Motor Controller");
  // Sets the two pins as Outputs
      pinMode(stepPin,OUTPUT); 
      pinMode(dirPin,OUTPUT);
      pinMode(enPin,OUTPUT);
      digitalWrite(enPin,LOW);
      pinMode(inPinLeft, INPUT);
      pinMode(inPinRight, INPUT);
      Serial.println("System Ready!");
      delay(500);
    }
        void loop() {
          valLeft = digitalRead(inPinLeft);
          valRight = digitalRead(inPinRight);
            if(valLeft == HIGH){
              digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
  // Makes 200 pulses for making one full cycle rotation
                  for(int x = 0; x < 800; x++) {
                  digitalWrite(stepPin,HIGH); 
                  delayMicroseconds(500); 
                  digitalWrite(stepPin,LOW); 
                  delayMicroseconds(500); 
                delay(15000);
                  for(int x = 0; x < 800; x++) {
                   digitalWrite(dirPin,LOW); 
                  digitalWrite(stepPin,HIGH); 
                  delayMicroseconds(500); 
                  digitalWrite(stepPin,LOW); 
                  delayMicroseconds(500);
          }     
       }
    }
      delay(1000); // One second delay
            if(valRight == HIGH){
                digitalWrite(dirPin,LOW); //Changes the rotations direction
  // Makes 400 pulses for making two full cycle rotation
                 for(int x = 0; x < 800; x++) {
                 digitalWrite(stepPin,HIGH);
                 delayMicroseconds(500);
                 digitalWrite(stepPin,LOW);
                 delayMicroseconds(500);
                delay(15000);
                  for(int x = 0; x < 800; x++) {
                  digitalWrite(dirPin,HIGH); 
                  digitalWrite(stepPin,HIGH); 
                  delayMicroseconds(500); 
                  digitalWrite(stepPin,LOW); 
                  delayMicroseconds(500);
              }
           }
        }
      delay(1000);
    }

You have the closing brace } for your first FOR loop in the wrong place. It should be before the delay(15000).

…R