Servo not rotating 180 degrees

I am trying to get my DFRobot servo to work:
http://www.dfrobot.com/index.php?route=product/product&product_id=120

I am using the sample sketch that is provided by the IDE. I am using external power for the servo, so that the Arduino is not stressed on that part. The code is:

#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(8, 544, 2400);  // 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
  }
  
  
  // myservo.write(0);
}

My problem is that I am unable to sweep the full 180 degrees that is supported by the servo. I guess the rotation is around 120 degrees. I have not found any solution for this.

Is anyone been able to use this servo as it is supposed to be.

Are you 100% sure that it actually can do 180 degrees?

I got a few 180 degrees servo's too, but not one of them can actually do 180

Below is simple servo test code that might be of use in testing your servo.

// zoomkat 10-4-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// for IDE 0019 and later
// Powering a servo from the arduino usually DOES NOT WORK.

String readString;
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

void setup() {
  Serial.begin(9600);
  myservo.attach(7);  //the pin for the servo control 
  Serial.println("servo-test-21"); // so I can keep track of what is loaded
}

void loop() {

  while (Serial.available()) {
    delay(10);  
    if (Serial.available() >0) {
      char c = Serial.read();  //gets one byte from serial buffer
      readString += c; //makes the string readString
    } 
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string 
    int n;
    char carray[6]; //converting string to number
    readString.toCharArray(carray, sizeof(carray));
    n = atoi(carray); 
    myservo.writeMicroseconds(n); // for microseconds
    //myservo.write(n); //for degees 0-180
    readString="";
  } 
}

Not all servos have a mechanical 180 degree travel, so 120 degrees may be the mechanical limit for your servo. Also some servos require pulse widths shorter and longer then the standard widths of 1 and 2 millisecond provided by the arduino servo command when using degree values of 0 and 180 respectively.

There is a writeMicroseconds() command where you can give the pulse width commands longer then 2millec and shorter then 1 millisecond to determine how much 'over-travel' your specific servo has. http://arduino.cc/en/Reference/ServoWriteMicroseconds

Lefty

Not all servos have a mechanical 180 degree travel, so 120 degrees may be the mechanical limit for your servo.

Per the link provided for the servo: "The DF15MG is a double bearing, high torque 180 degree rotation servo." Still could have mechanical issues.

I am still unable to rotate the full 180 degrees. The servo shaft can rotate over 180 degrees; but the Arduino is not able to control it that way.

Maybe I have to live with it.

Have you tried the writeMicroseconds method?

I have tried to delayMicroseconds; same issue. I will now try the library from IDE 16. It seems that the servo library and NewSoftSerial don't work together. Maybe that gives me the 180 degrees too?

It seems that the servo library and NewSoftSerial don't work together.

In the code you posted, you are not using NewSoftSerial, so the relevance of this observation escapes me.