0

I'm testing a servo using varspeedservo.h and it rotates to 180 degree on start and then rotates back to programmed position. Here is the code:

#include <AFMotor.h>
#include <VarSpeedServo.h>
VarSpeedServo myServo;

void setup()
{
  myServo.attach(10);
}
void loop()
{
  myServo.slowmove(0, 30);
  delay(5000);
}
| improve this question | | | | |
  • And what's your question? – ratchet freak Oct 6 '17 at 12:08
  • It should not show such behavior. How can i fix it? – smc Oct 6 '17 at 12:09
  • I suspect its finding its limits. You could try setting the position to 0 before you attach (no idea if that will work) – Code Gorilla Oct 6 '17 at 12:13
  • I just tried it but not working. Seems this issue comes only when I'm using Varspeedservo.h. – smc Oct 6 '17 at 12:16
  • could it be reversed, try setting it to 180 and see if it moves towards zero, if so just map it map(pos, 0,180,180,0) and success – Magic-Mouse Oct 6 '17 at 12:25
1

You will need to open up the VarSpeedServo library source code and read through it to understand how the library actually works with your sketch.

Consider that you have not setup an initial position before issuing your first "slow moving" command. It may be by setting an initial position before assigning a pin to the servo, you may prevent any unexpected movement.

Try something (for your code) like "myServo.wirte(0,0)" where the first argument is the position and second is the speed.

| improve this answer | | | | |
  • I added myServo.write(0,0); before attaching and it's working fine. Thank you. – smc Oct 6 '17 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.