title: I can't get my stepper motor to run through the loop I have built for it
body: <p>So I have tooled around a bit more with my stepper motor and my button sensor (I want to have the motor stop when the button is pressed; which I have for the most part figured out).  However, in an effort to simplify my code I have managed to get my motor to stop moving altogether.  In the code that follows the idea was to condense the main actions of the motor (to raise the platform up to the glass, take a picture, then to lower back down and repeat the process) by containing the majority of the actions within a single if statement so that the computer would have a better shot at reading it the way I intended.</p>
  
  <pre><code>#include &lt;AccelStepper.h&gt;
  const int buttonPin=4;  //number of the pushbutton pin
  const int opto_shoot=2;  // Pin that controls the shoot function
  int maxDistance=-12000;  //intial distance for motor to move
  int button_state=0;
  int sensorPin=0;  //select input pin for the photocell
  int sensorValue=0;  //variable to store the vaule coming from the photocell
  int motorSpeed = 9600; //maximum steps per second (about 3rps / at 16 microsteps)
  int motorAccel = 80000; //steps/second/second to accelerate
  int motorDirPin = 8; //digital pin 8
  int motorStepPin = 9; //digital pin 9
  
  
  //set up the accelStepper intance
  //the "1" tells it we are using a driver
  AccelStepper stepper(1, motorStepPin, motorDirPin); 
  
  
  void setup(){  
    pinMode(buttonPin,INPUT);  //set that the button is an input
    pinMode(opto_shoot,OUTPUT);  // set the pin that controls the shoot function
    stepper.setMaxSpeed(motorSpeed);
    stepper.setSpeed(motorSpeed);
    stepper.setAcceleration(motorAccel);
  
  }
  
  void loop(){
     stepper.moveTo(maxDistance); //move 2000 steps (gets close to the top)
     stepper.run();
     if (digitalRead(buttonPin) == HIGH){
         stepper.stop();
         stepper.runToPosition();
         digitalWrite(opto_shoot,HIGH);  //SHOOT
         delay(500);
         digitalWrite(opto_shoot,LOW);
         delay(1);
         goto Lower;  }
   //      for(int i=0;i&lt;36;i++)
   //        Serial.read();
   //
        else{   
    if(stepper.distanceToGo() == 0){
      stepper.stop();
      stepper.runToPosition();
      stepper.moveTo(maxDistance);
    }
     }
     Lower:{
      maxDistance=-1*(maxDistance+500);
         stepper.moveTo(maxDistance);}
     //these must be called as often as possible to ensure smooth operation
    //any delay will cause jerky motion
    stepper.run();
  }
  </code></pre>
  
  <p>Please help me to understand where I have gone wrong with this code.  </p>