Servo's Freezing

I have a hxt900 servo, and when using both example sketches included in Arduino 1.0, the servo (and a second identical one) freeze, quit, operate erratically, etc. Checked the wiring to make sure it's solid, and correct. I also checked to see the pot was being read properly.

The "L" light on my 2560 lights at the same time the servo "shifts" 2-5 degrees or so (every 9 seconds)

Anyone else having similar issues?

// Controlling a servo position using a potentiometer (variable resistor) 
// by Michal Rinott <> 

#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 
int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin 
void setup() 
  Serial.begin(9600);          //  setup serial
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
void loop() 
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) 
//  Serial.println(val);
  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180) 
  myservo.write(val);    // sets the servo position according to the scaled value 
//  Serial.println(val);
  delay(15);                           // waits for the servo to get there 

How is it powered? If from the Arduino, that's likely your problem.

yes, it's powered from the arduino, which is powered from my laptop usb.

Servos generally draw more current than the Arduino can supply, indeed you may well damage it in this way. You need an external power supply for the servos and connect ground from it to Arduino ground.

That did the trick. I found that that particular servo can peak at 750ma, so no wonder. Two AA's in series fixed it up for me. Thanks. I'll post the video, schematic, etc., shortly at

Two AA's in series fixed it up for me.

That sounds rather strange and most likely dangerous for the servos? In series with what? If in series with the arduino +5vdc that would give the servos +8vdc to their power input, which is much higher then the common 4.5to 6vdc power specification for most hobby servos and risks damaging the servos.


Two AA's in series is 3v. A little low for this servo, but it's what I had, and worked fine.

Below is the typical servo wiring setup for an arduino. 4 AA batterys in series would gvie ~6v for best servo performance. Note that the servo power supply and arduino grounds need to be connected.

That's what I ended up doing.