The servo library takes an int as parameter for the angle. I just checked the precision of my servo, a Turnigy TGY-90S (sorry, eBay was the first site to include at least some stuff about the servo). I attached a small laser light to the servo and had it rotate in five degree steps, shining at a wall so that the 5 degrees became somewhat 10 cm. I ran different kinds of loops back and forth and had the red spot still for a second. Seems the accuracy of the servo is pretty good. Of course, with more load it might get worse. Then I had one pattern where it jumped back and forth four times +-10 degrees to one spot, then ascending just one degree and jumped again back and forth to that spot, then again advanced one degree etc. Here:
void loop() {
for (pos = 60; pos <= 100; pos++) { //
// in steps of 1 degree
myservo.write(pos-10);
delay(1000);
myservo.write(pos); //
delay(1000);
myservo.write(pos+10);
delay(1000);
myservo.write(pos); //
delay(1000);
myservo.write(pos-10);
delay(1000);
myservo.write(pos); //
delay(1000);
myservo.write(pos+10);
delay(1000);
myservo.write(pos); //
delay(1000);
}
}
This particular test convinced me that the servo is pretty accurate. The four times the red spot hit what was meant to be the same spot, the deviation was less than one degree. That made me wonder why the servo library deals with ints. One should be able to set the servo to any float degree. Correct me if I'm wrong, but the servo reads an analog signal, doesn't it? A pulse length of 1 to 2 ms, right? And 1.5 ms means middle position or 90 degrees.
The precision of the pulse is some microseconds, right? Having everything rounded to degrees at some point just doesn't make sense. If the smallest time unit inside the processor would be say 5 µs, we would have 200 such units in one ms. And instead of having just 180 discrete degrees, we could have a continuum from 0 to 180 degrees. The continuum would make sense if we for some reason would like to divide the 180 degrees in say 170 equal steps. Having each step rounded to the nearest degree would make the steps of different size. It's a tiny error but unnecessary, if the servo itself doesn't deal with ints, only analog lengths of pulses.