Question about Servo library

I am confuse about "servo.h" and "SoftwareServo.h"... Would somebody help me to clarify them ?

First, someone said "servo.h" can only control 2 servo (Max) and it should be connected to pin 9 and 10, isn't it ?

Then "SoftwareServo.h" can control 13 servo (Max) for arduino duemilanove, isn't it ? ( But it said that SoftwareServo.h will disable the PWM function of pin 9 and 10 (, so the library can or can't control a servo motion that connect to pin 9 and 10 ?

So, what is the different between "Servo.h" and "SoftwareServo.h" ?

Many Thx.

I haven't looked at the code for both of them (by that I mean I may be making this up), but this is what I think the difference likely is.

The version that only allows 2 servos on 9 and 10 is using timer1 to generate pulses via one of the pwm modes, while the version that allows up to 13 to be controlled is using the same timer, but is instead switching the various pins in the timer1 overflow ISR. The first method requires less software overhead and probably offers more, albeit unneeded, granularity but the timer can only do two different pulse lengths at the same time and the servos must be connected to pins 9 and 10.

If I'm right about the two libraries you are talking about then neither have the 2 servo limit, you can use servos on pins 9 and 10, you just can't expect to use them for pwm while using the library to control servos on other pins.

kokpat: So, what is the different between "Servo.h" and "SoftwareServo.h" ?

Servo.h is the library delivered with the Arduino which can use on the Duemilanove or the Uno up to 12 servos at the same time. It takes care to refresh the servos via an interrupt function connected to Timer1 and you don't have to worry about it at all. It just works. Use this one.

SoftwareServo.h is a less efficient library where you need to take care of the refresh yourself. The only reason to use it is if Timer1 is blocked by some other library and a few rare cases where Servo.h can't be used for other reasons.

As the pwn mentioned by Growler and the limit to two servos on fixed pins: Forget it. That's either hogwash or information so old that it doesn't apply to the libraries available today.


The PWM two servo limit mentioned by Growler was for the Arduino Servo library prior to version 0017. That old version could be useful in applications where the interrupts used by the current Servo library interfere with other code relying on precision interrupts, such as NewSoftSerial.

Thx u very much.