Control Stepper Motor Direction & Speed with Zyltech Step Driver & Limits

I'm trying to control a stepper motor with the Zyltech Driver. I want to control direction of a belt driven dolly with 2 pushbuttons and speed with a pot. I got this all working. Where I have run into problems is when I want to add limit switches to stop the dolly from moving when it hits a limit switch. I have tried numerous configurations but can't seem to get it right. I'd appreciate any suggestions. Here's my code.

int Stepping = false;
int Spd = 1500;
int count = 0;
int interval = 1000;
int potPin = A5;
int val = 0;

#define Limit01 6  // Pin 6 connected to Limit switch out
#define Limit02 7  // Pin 7 connected to Limit switch out

void setup() {
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);

  pinMode(2, INPUT);
  pinMode(3, INPUT);
  Serial.begin(9600);
}

void loop()
{
  count = count + 1;
  if (count > interval) {
    //    Serial.println (count);
    count = 0;
    Getpot();
  }
  if (digitalRead(Limit01)) {
    if (digitalRead(3) == LOW && digitalRead(2) == HIGH) {}
    else {  //  if limit switch is not activated, move motor clockwise
    }
    {
      digitalWrite(8, LOW);
      Stepping = true;
    }
    if (digitalRead(Limit02)) {
      if (digitalRead(2) == LOW && digitalRead(3) == HIGH) {}
      else {  //  if limit switch is not activated, move motor clockwise
      }
      {
        digitalWrite(8, HIGH);
        Stepping = true;
      }
      if (Stepping == true)
      {
        digitalWrite(9, HIGH);
        delayMicroseconds(Spd);
        digitalWrite(9, LOW);
        delayMicroseconds(Spd);
        {
          Stepping = false;
        }
      }
    }
  }
}

void Getpot() {
  int val = analogRead(potPin);
  Spd = map(val, 0, 1023, 1500, 100);
  return;
}

Go check your braces. You've got the { and } all messed up. To the point that I'm not sure what you actually mean to do here. If you autoformat the code it becomes obvious that you only read Limit02 if Limit01 was high. Is that what you intended?

OK ..i would to periodically check the speed pot. Then I would like to see if limit switch 1 is active, if not then see if button one is pushed. If not then check if limit switch 2 is active, if not then see if button two is pushed then start over

These links may help
Stepper Motor Basics
Simple Stepper Code

also look up the AccelStepper library

...R

How are the limit switches connected? Appears that one side of each are connected to pins 6 & 7 what is the other end connected to? Are the switches normally open or closed? If the dolly is moving clockwise, which limit switch stops it, limit 01 or 02?