Accel stepper library, easy driver, limit switches

Hello,
I’m pretty much a noob at Arduino coding, though I’ve done a number of projects with stepper motors and Arduino. I’m excited to use the Accel library because I want to control multiple steppers from one Arduino. I’m using the motors to turn radio knobs, which only turn 180 degrees so I want to use photo interrupters to set limits for turning at each end. (I’m using these: http://www.sparkfun.com/products/9299) They basically function as buttons, giving a HIGH signal when they are open. I also want to send the dial to randomized positions, hold for a randomized period of time at that position and then go to a new position. I’ve written some code that I thought would do this, but it seems to be stuck in the final “else” part of the loop and the motor just sort of goes back and forth. (I know that the buttons are properly connected and working because when I run other code they behave as expected) I’m using Easy Driver 4.4. If anyone can see what I’m doing wrong or has some code that I could adapt for this, I’d be very grateful.
Thanks!
HH

#include <AccelStepper.h>

// Define two steppers and the pins they will use
AccelStepper stepper1(1, 4, 3);//1 means a stepper driver (with Step and Direction pins)
//AccelStepper stepper2(1, 7, 6);//1 means a stepper driver (with Step and Direction pins)
//AccelStepper stepper3(1, 10, 11);//1 means a stepper driver (with Step and Direction pins)next is step, then direction

//int pos1 = 400;
int pos3 = 400;
int topBut= 6;
int botBut = 8;
int topButVal = LOW;
int botButVal = LOW;
//int ledPin = 13;
long dtg = 10;
//long pos2 = 200;


//boolean direction = false;
//int pos2 = 5678;
//int pos3 = 4600;

void setup()
{  
  stepper1.setMaxSpeed(100);//The desired maximum speed in steps per second. Must be > 0. Speeds of more than 1000 steps per second are unreliable.
  stepper1.setAcceleration(1000);
  Serial.begin(9600);
  pinMode(botBut, INPUT);
  pinMode(topBut, INPUT);
  //pinMode(ledPin, OUTPUT);
  //stepper2.setMaxSpeed(2000);
  //stepper2.setAcceleration(800);
  //stepper3.setMaxSpeed(2000);
  //stepper3.setAcceleration(800);
}

void loop()
{
  topButVal = (digitalRead, topBut);
  botButVal = (digitalRead, botBut);
  if ((stepper1.distanceToGo() == 0) && (botButVal==LOW) && (topButVal==LOW))
  {
    delay (1000);
   Serial.print ("DTG");
    Serial.print (stepper1.distanceToGo());
    stepper1.moveTo(random(-400,400));
    
    
  }
  else if ((stepper1.distanceToGo() != 0)&&(botButVal==HIGH))
  {
    Serial.println ("BOThigh");
    
   stepper1.moveTo(-stepper1.currentPosition()+(random (-200,200)));
   
 }
   else if ((stepper1.distanceToGo() != 0) &&(topButVal==HIGH)){
  Serial.println ("TOPhigh");
  stepper1.moveTo(-stepper1.currentPosition()+(random (-200,200)));
   
 }
    else {
      
      stepper1.moveTo(random(-400,400));
    
    Serial.println("TOPLOW;BOTLOW");
    
  }
  stepper1.run();

}

I also want to send the dial to randomized positions, hold for a randomized period of time at that position and then go to a new position.

I see where you move to a new random position if you are at the last randomly selected position, and I see where to move a random amount (in possibly the wrong direction) if you are not. I don't see where you stand still a random amount of time.

I think that the limits for the random call are wrong in two places. If the limit switch is pressed, you need to move one way a positive amount. Choosing a negative random number does not make sense.

I see that you are not using the internal pullup resistors for the limit switches. I do not see where you describe how the switches are wired. I do not understand why you don't use the internal pullup resistors.