 
     logData();
     updateDisplay();
+    justMoved[inputNum] = false;
   }
   else if (PIStates[inputNum] == 1) {
     //need to replace pellet
-    Serial.print(F("Replacing pellet #"));
-    Serial.print(String(inputNum + 1));
-    Serial.println(F("..."));
-    moveMotor(inputNum);
-    delay(500);
+    if (!justMoved[inputNum]) {
+      Serial.print(F("Replacing pellet #"));
+      Serial.print(String(inputNum + 1));
+      Serial.println(F("..."));
+      moveMotor(inputNum);
+      justMoved[inputNum] = true;
+    }
+    else
+    { delay(500); justMoved[inputNum] = false; }
   }
   
   else if (PIStates[inputNum] == 0 & PIStates[inputNum] != lastStates[inputNum]) {

File dataFile;

const int MOTOR_STEPS_PER_REVOLUTION = 513;
const int STEPS_TO_INCREMENT = 32;
Adafruit_MotorShield gMotorShield = Adafruit_MotorShield();
Adafruit_StepperMotor *motor1 = gMotorShield.getStepper(MOTOR_STEPS_PER_REVOLUTION,1);
Adafruit_StepperMotor *motor2 = gMotorShield.getStepper(MOTOR_STEPS_PER_REVOLUTION,2);

  detachInterrupt(digitalPinToInterrupt(PHOTO_INTERRUPTER_PIN_2));
  sleep_disable(); //disabling sleep
  power_usart0_enable(); //re-enabling serial
  Serial.println(F("Exiting sleep."));
  delay(300);
}

