title: Accelstepper motor button stop and continue to next position
body: <p>What I like to do is make a stepper motor run into one direction till a sensor gives a HIGH signal, then it should stops. </p>
  
  <p>I figured this part out, but now I want the stepper proceed turning after a delay of a few seconds with the sensor signal still HIGH</p>
  
  <p>Can somebody help me?</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;AccelStepper.h&gt;
  #define HALFSTEP 8
  
  // Motor pin definitions
  #define motorPin1  3     // IN1 on the ULN2003 driver 1
  #define motorPin2  4     // IN2 on the ULN2003 driver 1
  #define motorPin3  5     // IN3 on the ULN2003 driver 1
  #define motorPin4  6     // IN4 on the ULN2003 driver 1
  
  // Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
  AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
  
  
  
  void setup() {
  
    Serial.begin(9600);
    pinMode(7,INPUT);
  
    stepper1.setMaxSpeed(600);
    stepper1.setAcceleration(200);
    stepper1.setSpeed(100); 
  }
  
  void loop(){  
  
      if(digitalRead(7) == 1)  
      {
          stepper1.move(640000);
          stepper1.run();
      }
  
      if(digitalRead(7) == 0)   
      {
          stepper1.setCurrentPosition(0); 
          stepper1.stop();
  
          //from here it does not work, the stepper is not going to move
          delay(2000);
  
          stepper1.move(640000);
          stepper1.run();     
      }
  } 
  </code></pre>