We are trying to control a robotic arm using the Tower Pro MG 996R 180° high torque servo.

Firstly we tried to power the servo from Arduino's default 5V, but it didn't work, then we power it from an external source, the servo ran, but only in one direction. Then it stopped rotating. We used the sweep code from the Arduino examples to test the motor.

Here's the code:

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0;    // variable to store the servo position

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object

void loop() {
  for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
    // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position

Can anyone please specify what are we doing wrong, and what is the right way to do it.

migrated from electronics.stackexchange.com Mar 11 '16 at 18:18

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

  • 1
    Show how you have the servo connected to the Arduino. Did you remember to connect the ground from the servo to the Arduino ground? – JRE Mar 11 '16 at 11:14
  • The default pulse width range for servo.write() is 544us to 2400us, which can overdrive some servos. Try limiting the range to 1~2ms with myservo.attach(9,1000,2000); – Bruce Abbott Mar 11 '16 at 17:25

The Arduino's 5V is hardly enough for driving servos. I found that even a simple 9g micro servo draws well over 1A spikes, which causes the board to reset itself.

  • Power the servo from an external battery pack (e.g. 3xAA or 4xAA batteries will do);
  • Ensure that the GND of the battery pack is connected to the GND of the servo as well as to the GND of the Arduino;
  • So you'll have two wires between the Arduino and the motor: GND and the driving signal.

It has to work, servos are pretty standard stuff. However there are many complaints against this particular type at this link Towerpro MG996R 10kg Servo 10kg / 0.20sec / 55g.

  • These have a label with "towardpro"? Probably counterfeit, should return to shop immediately. – Paul Mar 12 '16 at 7:30
  • @Gee Bee we did exactly that, except instead of using battery pack, we used an external 5v dc power source. grounds are connected as you described, but its still rotates in one direction and stops rotating at a certain angle. however I can feel the motor running, but the shaft is not rotating... any suggestion ?? at_Paul... its "towerpro**" so I guess its not counterfeit.... – Sashanka Kumar Pramanik Mar 12 '16 at 12:27
  • Can you try to drive a simple standard model servo? That will rule out any problems of software and connections. I found that even micro servos draw 1.5A spikes at start, so you need a very good 5V power source. A PC power supply would do, but an USB charger is not. Although it sounds silly, give a try to the AA batteries. They provide much better transient responses than an off the shelf power supply. I had a project where servo anomalies drove me crazy - all caused by power supply glitches. – Gee Bee Mar 12 '16 at 21:44
  • Thanks a lot bro... you are a life saver :D :D ... this time we powered the servo directly from computers USB, instead of external power supply.. and it WORKED :D really appreciate your help... and lesson learned... power can be brutally preposterous. – Sashanka Kumar Pramanik Mar 13 '16 at 12:39
  • Good that it worked. Note that computer USB is a way too weak to power a brutal servo, sometimes I managed to trigger the short circuit protection of the PC just because of the sudden power draw of a servo can be huge. You may improve the situation a bit by connecting a 1000uF/10V electrolyt capacitor to the power pins of the servo connector, but I advise to use a dedicated power supply or a good battery with small internal resistance. – Gee Bee Mar 13 '16 at 20:56

Si no me equivoco tiene 64 pasos. El servo no deberia ir de grado en grado sino por c/u de los 64 pasos. 180 grado / 6r es 3 grados x cada cambio de paso step to step. ? Atte.

If I'm not mistaken in 64 steps. The servo should not go from grade to grade but by c / u of the 64 steps. 180 degree / 6r is 3 degrees x each step change step to step. ? Atte.

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.