Stepper motor is only moving one step at a time with an IR sensor I am trying to get both the motors to run simultaneously once the motion detector senses an obstacle. Both motors run fine by themselves but when I implement the sensor the motors only move one step per motion detected.  


Arduino Mega (ATMega 2560)
(2) NEMA 17 stepper motor/ A4988
Digital IR Sensor Module


#include &lt;Arduino.h&gt;
#include &lt;avr/io.h&gt;
#include &lt;AccelStepper.h&gt;

AccelStepper stepper(1,5,4); // w/Driver (1,Step, Direction)
AccelStepper stepper2(1,9,8);

const int pin_ir_in = 3;
int prev_state = 1;
int curr_state = 1;
int counter =0;


void setup() {
  Serial.begin(9600);
  pinMode(6,OUTPUT); // Enable
  pinMode(10,OUTPUT);

  digitalWrite(6,LOW); // Set Enable low
  digitalWrite(10,LOW);
}

void loop() {
  digitalWrite(6,LOW); // Set Enable low
  if (stepper.distanceToGo() == 0)
  { 
    delay(1000);
    stepper.moveTo(100);
    stepper.setMaxSpeed(200);
    stepper.setAcceleration(100);

  }

   digitalWrite(10,LOW); // Set Enable low
     if (stepper2.distanceToGo() == 0)
  {  
    delay(1000);
    stepper2.moveTo(100);
    stepper2.setMaxSpeed(200);
    stepper2.setAcceleration(100);

  }


int curr_state = digitalRead(pin_ir_in);
if (curr_state != prev_state)
{
  if (curr_state == 0)
  {
    stepper.run();  // Actually makes stepper move
    stepper2.run();  
    delay(500);
  }
  prev_state = curr_state;

}

}
As chrisl said, you need to call run repeatedly.

I tried to rewrite the code you've given, though I'm not entirely sure what it is you try to achieve.

void loop() 
{
  stepper.run();  // Actually makes stepper move
  stepper2.run();  


  int curr_state = digitalRead(pin_ir_in);
  if (curr_state != prev_state)
  {
    if (curr_state == 0) // Motion sensor activated
    {
      stepper.moveTo(100);
      stepper.setMaxSpeed(200);
      stepper.setAcceleration(100);
      stepper2.moveTo(100);
      stepper2.setMaxSpeed(200);
      stepper2.setAcceleration(100);
    }
    prev_state = curr_state;
  }
}