Servo twitching

I have this servo: http://www.ebay.com/itm/HOE-SEL-SG90-9-Gram-Micro-9g-Servo-For-RC-Airplane-Car-Boat-US-Sel-/151049686413?pt=US_Scissors_Shears&hash=item232b434d8d

I'm using it with this code:

#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(10);  // attaches the servo on pin 10 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>=1; 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 
  } 
}

When I run the code the servo just keeps twitching on and off. I've verified the connections and they're correct. If I move the servo by hand a small bit it begins to move then it starts twitching again. It seems that the issue is that it's not moving enough to get to the next tooth on the servo gear, so it is in an endless loop of moving a small bit and then springing back. I've checked the servo and the teeth are not stripped out. I've tried changing the degrees and the delay in the code and it didn't seem to help, but I appreciate any help offered and I'm open to suggestion.

Thanks, Michael

How are you powering your arduino board and servo? Supplying improper power to servo(s) is one of the most frequent problems for beginners.

Lefty

I have the exact same servo here. I just ran your code. The servo moves back and forth thru its full angle as expected. Even if powered directly of the Arduino board (not recommended) it still works correctly.

The servo does stutter slightly but that is expected from very cheap servos.

How did you connect the servo? What is its source of power? Its also possible that you have a defective servo. Try another similar servo.

Joe

Sorry for the late response, we lost our home internet. But anyways, i'm powering the servo using the ground and the +5 on the arduino board.

Disconnect the servo. Can you turn the servo by hand by grasping the horn? Gently, do not force it. Have you tried another servo?

Hy i have same servo only my with the code posted here it goes all the way to the right and stays there.
I tried different codes all the same result.
If i take the power of i am able to move the position of the servo (is not mechanically blocked) but when power is one will go back to right and stay there.
I am new to arduino and servos and I don't know what is the problem.
I plug servo in the fallowing way : brown GND, red +6 (from extra batteries) and yellow for arduino signal

Thank you for your help.

Make sure the servo external power and arduino grounds are connected like below.

Tank's for quick response. I decided to get power from arduino instead of battery and now works. Just so that I have to connect the GND and it works. Thanks and sorry for not not looking properly at the schematic