Doh! ![]()
or ...
if (digitalRead(1) == HIGH) {
  stepper.step(-previous);
  // reset the previous value to zero
  previous = 0;
 }
 else {
  stepper.step(stpPos - previous);
  // remember the previous value of the sensor
  previous = stpPos;
 }