Let's Make Robots!

Arduino 20 Servos, 4 Pins, Variable Refresh Rate

More Servos, Less Pins, Less Cost

Some time ago I posted a library for running ten servos from an Arduino using just 2 pins. I have extended it to 20 Servos from 4 pins.

The library has a variable refresh rate determined by the number of servos, servos can be split across two banks for higher refresh rates.

Original 10 Servo library with all the background here -


New version with support for split banks for higher refresh or just more servos here -


Duane B


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Others may think you're wasting your time re-inventing the wheel on this, but I think it's truly AWESOME. These ICs cost nothing and are available in shops locally anywhere. Even here (Cordoba, Argentina) where it's hard to get anything and what little you can get usually comes at a ludicrous price. Furthermore having stuff shipped here is about as pleasant an experience as getting kicked in the nuts.

Sooo... I'm sold. I wanna try this out right away. At first glance it does seem a bit complicated/messy, so I was wondering, since this thread is rather old, if you (Duane) are still around for giving a bit of advice should it be needed? For starters I'd like to ask if there are any problems/inconveniences you've become aware of in the meantime?

Anyway thanks for sharing this...

Thanks Duane for sharing this. I know I've seen a number of people discussing here making a servo controller from a micro and will find this information useful.
I don't think I've seen you mention it here about your gig over at microcontroller central but I've enjoyed reading your posts over there. Sorry for spoiling your anonymity if that was your intention.
But we are a bit micro centric here anyway.

Hi, I had to look up microcontroller central and then search for a Duane. While I am Duane B, I am not Duane Benson.

Duane B

Sorry about the confusion there. I'm not sure how I came to that assumption now other than similar names I thought I'd seen Duane Benson talking about a project similar to what you'd been working on. An rc beetle I think it was. But I've got my wires crossed, please excuse me for the error.
It doesn't take away from the usefulness of what you've posted however.

I Guess I should be flattered to be taken for someone with a lot more background than I have.



It's always great to learn more about the people behind their acronyms - especially if they have such a massive background like Duane.

I like what you've done but there is an existing device that you may want to look at before you re-invent the wheel any further.

The PCA9685 is an I2C controlled, programmable PWM generator with 12bit resolution that was originally designed for LED control. Adafruit have already turned it into a servo controller and have a library for it.

This allows your I2C port to control up to 992 servos with only 2 pins and very little processing power. With 12 bit resolution this is a nice solution.

Hi, If you can tolerate the usual micro controller ticks, the library here will get you 20 servos on a standard Arduino with just 2 additional 30 cent components.

The device you mentioned will ( I assume it does, bit pointless if it doesn't) get rid of these ticks for 16 servos at a cost of 15 dollars. I recon an ATMega168 based Arduino can be built for 5 dollars and will support 18 servos with the library I will release next week. Its not a massive saving and the library is just a faster servo library, I have not added any coms and I am in no rush to reinvent the wheel but if someone wants to build an Arduino servo controller its a cost effective option and the new library will get you on the right path quickly.

Duane B


I'm not sure what "ticks" you are refering to. When I have had my Spider controller on a 100MHz digital oscciloscope there werre no glitches in the signal. It may depend what other code you are running as some libraries use timer interrupts.

Adafruit might charge $15 but you can buy the chip for far less.


I am generally running servos in the same projects that I am also reading RC Signals. The RC Signals generate around 700 interrupts per seconds, thats on top of the arduino time (micros/millis) interrupts and the servo library interrupts. When this lot all try to happen in the same instant you get ticks. Here is a link with more details and what I have done to overcome it -


Duane B