Servos fail to move

So this is the issue new to Arduino have a Arduino Uno board right now its powered off a 9v battery. I’ve attempted to use the sweep example set up a number of times on multiple different HiTec hs-485hb servos and for some reason they are not functioning. At most the servos move a fraction of an inch if anything. CC

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

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(30); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(30); // waits 15ms for the servo to reach the position
}
}

Servos draw too much current from the arduino if powered from the arduino 5V shield pin, but sometimes you can get just one to work wired that way. However trying to power the board and servo from one of those wimpy 9 volt batteries is sure to fail.

Does the servo work if you disconnect the 9 volt battery and power the board via USB connection?

Lefty

I've tested it via USB as well and still get the same response from the servo. CC

Appropriate way to externally power a servo.

When I first got my servos, I searched through old wallwarts until I found one that output 6V 500mA which does the job. More current would be nicer if you can find it. Alternatively, four AAs in series will do it if you can figure out a way to connect them together.