netlabtoolkit / VarSpeedServo

Arduino library for servos that extends the standard servo.h library with the ability to set speed, and wait for position to complete
GNU Lesser General Public License v2.1
291 stars 127 forks source link

servo.wait() method not working #18

Closed GownerCode closed 6 years ago

GownerCode commented 6 years ago

Here is a simple example of this issue:

#include <VarSpeedServo.h>
VarSpeedServo servo;

void setup() {
  servo.attach(10);
  servo.write(90);
  servo.wait();
  servo.detach();

}
void loop(){}

In this example, the servo doesn't move at all because it is detached before it can move despite the method wait() being called before detach(). I want to detach my servos after movement to keep them from jittering. Is there any way I can do that?

pvanallen commented 6 years ago

You could use the isMoving() function in your loop() to wait for the move to complete before you detach. Keep in mind that this library is designed to work primarily in the loop() because each time through the loop the servos are updated a little bit until the moves are complete.