# Problem with Arduino UNO and RC servo

This is my first attempt to work with a servo and I'm using this tutorial. I have a "TowardPro MG996R DIGI HI TORQUE" servo directly connected to my Arduino Uno as follows:

I also created the following code to upload onto the Arduino:

#include<Servo.h>

Servo myservo;
int servoPin=9;

void setup(){
myservo.attach(servoPin);
}

void loop(){
for (int i=0; i>= 20; i+=20){ // increment by 20 degrees
myservo.write(i);
delay(1000);
}
}


After hooking up the servo wires to the Arduino (unpowered), I then hooked up the USB power source to my Mac computer (no code uploaded yet). However when I did this, I noticed a very strange reaction:

1. The servo motor instantly started rotating in small increments about once every second or so, like a pulsing.

2. The message "A new network interface has been detected" keeps popping up and closing at the same frequency as the servo's motor.

3. The periodically appearing message prevented me from uploading my code onto the Arduino.

Of course, I thought something was wrong and promptly tried to disconnect the power source and reconnect it several times with no improvement. So, I tried the following steps:

1. Disconnect the USB power to the Arduino.
2. Disconnect the servo wires from the Arduino.
3. Reconnect the power usb to the Arduino.
5. Disconnect USB power source.
6. Reconnect servo wires to the Arduino.
7. Reconnect the USB power source.

Now, I'm having the following problem:

1. The servo motor does not rotate.
2. A hissing noise is coming from the servo.
3. The message "A new network interface has been connected" does not appear.
4. My computer does not recognize anything at all connected to the usb port where the Arduino is connected to.

At this point, I have no idea what the problem is or how to fix it. Any help to understand where I went wrong and how to remedy it would be greatly appreciated.

• What is in servo.h and probably the associated C file? – Matt Young Dec 15 '13 at 2:49
• @MattYoung: See this header file – Paul Dec 15 '13 at 2:52
• I'd try shutting down the PC and physically removing power for 10 seconds or so. I used to have a motherboard and when it detected an overcurrent condition (probably what has happened here) that was the only thing that would clear it. – PeterJ Dec 15 '13 at 2:56
• "High torque" implies high power. Once your USB port cools off, supply external power to the Arduino or servo. – Ignacio Vazquez-Abrams Dec 15 '13 at 3:47
• Don't run motors / servo's from you USB. They draw too much current and induce noise on the power supply lines. Your USB host may cut off one or more ports when this happens. – jippie Dec 15 '13 at 7:19

Your servo may behave erratically, and you may find that this only happens when the Arduino is plugged into certain USB ports. This is because the servo draws quite a lot of power, especially as the motor is starting up, and this sudden high demand can be enough to drop the voltage on the Arduino board, so that it resets itself.

If this happens, then you can usually cure it by adding a high value capacitor (470μF or greater) between GND and 5V on the breadboard

As others have commented, if your servo requires more current than the Arduino (or your USB port) can supply, you should provide a separate power connection for the servo.

Your USB port may be limited to 100mA or to 500mA, the Arduino may be able to provide slightly more current at 5V if it is connected to a power source through the barrel-jack connector. It depends on the specifications of the 5V regulator on your particular Arduino (or clone).

If you power the Arduino from a regulated 5V supply, you can draw higher currents from the VIN socket.

I note that some retailers of your servo suggest it be used with a motor controller board.

• I tried to fix the problem using a 470 microFarad and a 1000microFarad capacitor between ground and 5v, but this did not work. I then tried to connect the servo to a separate power source with the sensor wire connected to pin 9 on the arduino. This remedied my problem. – Paul Dec 20 '13 at 21:11

I tried to run the servo with the arduino connected to the PC and had the same issue as you, the servo drains a lot of power and work erratically

I bought a proto board with a power supply (2 outputs: 3.3v or 5v each). If I connected the circuit in one output, it didn't work, then I connect each one in different output and worked like a charm!

    void loop(){
for (int i=0; i>= 20; i+=20){ // increment by 20 degrees
myservo.write(i);
delay(1000);
}


Need to be corrected as follows:

void loop(){
for (int i=0; i <= 200; i+=20){ // increment by 20 degrees
myservo.write(i);
delay(1000);
}

• Actually both are wrong; however this cannot explain the observed behavior. The fundamental problem is not with the code, but with the fact that servos should not be powered from Arduinos or USB ports. – Chris Stratton Aug 25 '18 at 1:43

Sorry for the bump but I solved this in a different way.