I have a 270 degree servo motor (LD-3015MG) hooked up to an Arduino. The problem I'm having is that the angle I set it to, does not match the actual angle it actually goes to.
Here's the Arduino code:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo.write(180);
}
void loop() {
}
Firstly I would set it to 0 degrees, then I would set it to something like 180 degrees. But I can clearly see that the servo has rotated all the way to about 270.
Whats causing this? Is the Arduino library sending the wrong PWM signals for this type of servo? Is there not enough power going to the servo? Is there any way to calibrate a servo motor?
The servo in picture is not exactly the same model as the one I have:
The library's write
function only handles input from 0 to 180 which means on a 270 degree servo, 180 degrees represents a max value. I'd recommend switching over to use the writeMicroseconds
function as it's more clear what type of value you're working with.
write(120)
should produce close to a 180 degree angle.