From 2ad951e4fbae424e38d809e80a12fb23f90bf646 Mon Sep 17 00:00:00 2001 From: Paul Kerspe Date: Tue, 9 Jun 2020 00:21:12 +0200 Subject: [PATCH] updated example --- .../Example5_processMovement_in_own_task.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/Example5_processMovement_in_own_task/Example5_processMovement_in_own_task.ino b/examples/Example5_processMovement_in_own_task/Example5_processMovement_in_own_task.ino index bdb2d7e..8fdc693 100644 --- a/examples/Example5_processMovement_in_own_task/Example5_processMovement_in_own_task.ino +++ b/examples/Example5_processMovement_in_own_task/Example5_processMovement_in_own_task.ino @@ -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().