Skip to content

Commit

Permalink
updated example
Browse files Browse the repository at this point in the history
  • Loading branch information
pkerspe committed Jun 8, 2020
1 parent 2754743 commit 2ad951e
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ void loop()
// just move the stepper back and forth in an endless loop
if (stepper.getDirectionOfMotion() == 0)
{
delay(5000);
previousDirection *= -1;
long targetPosition = DISTANCE_TO_TRAVEL_IN_STEPS * previousDirection;
stepper.setTargetPositionRelativeInSteps(targetPosition);
delay(4000);
long relativeTargetPosition = DISTANCE_TO_TRAVEL_IN_STEPS * previousDirection;
Serial.printf("Moving stepper by %ld steps\n", relativeTargetPosition);
stepper.setTargetPositionRelativeInSteps(relativeTargetPosition);
delay(10);
}

// Notice that you can now do whatever you want in the loop function without the need to call processMovement().
Expand Down

0 comments on commit 2ad951e

Please sign in to comment.