Page 1 of 1

How to control one task then another

Posted: Wed Nov 30, 2022 5:58 pm
by Saylerjen73
Hi, I am wondering how I can do one task, have that finish, then do another.

For example, I want to change the 'setTargetPosition' then after it finished, have it move back.
step motor example code.png
Example code
(85.95 KiB) Not downloaded yet
Thank you!

Re: How to control one task then another

Posted: Thu Dec 01, 2022 12:22 pm
by jdecoux
To detect when your motor is done moving, you can either poll stepper0.getIsMoving() in a loop, or you can set up the stopped event handler to handle the event asynchronously (see setOnStoppedHandler for a brief example in the API).