0

I am using a XMG-996R servo motor. It is controlled by and Arduino Uno board. The problem is when I tell it to go to a certain angle, it will rotate to the desired position but then return to 0. The motor keeps rotating back and forth between the destination and 0 degrees. I tried this with different servos and they all do the same.

I am using 3 AA batteries as an external power supply. I have also tried using 4 AA batteries or a 9V battery. The same thing happens no matter the power supply.

My control wire is connected to the Arduino, positive is connected to the external power source. The negative is connected to the ground of the power source and the ground of the Arduino.

This is my code:

include <Servo.h>

Servo servo;

void setup(){
   servo.attach(9);
   servo.write(90);
}

void loop(){

}

I have also tried putting the write() into loop as well as putting servo.write() before servo.attach(). neither of these methods made a difference.

What can I do to make the servo rotate to the given degree and stay at that degree? Thanks.

migrated from electronics.stackexchange.com Dec 28 '18 at 16:41

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

  • 1
    This belongs in an Arduino forum, but I think you need to keep calling write to constantly send pulses to it. Move write into the main. – MadHatter Dec 28 '18 at 16:17
  • Yes, I tried that. the same thing happened. I increasing the amps. This fixed part of the problem. Now the servo rotates past the target, to the machine limit, back to the target degree and stops. – wilson wilson Dec 28 '18 at 16:38
  • I put a ceramic capacitor on the motor, now it works fine. – wilson wilson Dec 28 '18 at 18:23

Your Answer

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

Browse other questions tagged or ask your own question.