4 or more servos on an Arduino


The latest version of the Arduino software allows you to use more than two servos at a time. Curious Inventor has posted a demo showing how to run 4 servos from a keyboard input. The code should also work just fine on Arduino clones, like the Roboduino pictured above. They point out that if you are running version 12 of the software, some manual additions will be necessary.

17 thoughts on “4 or more servos on an Arduino

  1. The Propeller from Parallax has objects (read: “drivers”) freely available that can run up to 32 servos from just one of it’s 8 ALU’s (nicknamed cogs).

    Full Discloser: I have no formal association with Parallax… But I am a huge fan.

  2. i ordered my first arduino last week to start experimenting with it and to eventually use it in a project for class. I knew it was designed for only 2 servos (that’s what the spec said), but I just figured I’d multiplex myself out of that situation.

    thanks for the vid and the parallax recommendation!

  3. On a similar note, I have AVR 8535 code around somewhere that reads pre-USB computer joystick / pedal / button inputs and converts them into a pulse train for the Futaba buddy box protocol.. lets you take a cheapo 4-channel TX and use all the available outputs (7, generally) on the receiver. Only mod I made to the TX was to replace the spring-loaded buddy-box switch with a throw switch. The main issue I had was that the range on standard R/C gear is only about half a mile.

    Also, you don’t need individual hardware PWM for servo outputs.. use a single timer interrupt and a few bytes of RAM, toggle the output lines in the ISR. 1-2 ms pulses leave you gobs of time.

  4. I’ve been using the Lynxmotion SSC-32 for a little while with one of their robot arms, and i’m still trying to figure out how they’re doing it with an atmega 168 what seems to be 4 shift registers.

    Can anyone explain how you update 32 servos independently and still have time for serial IO? I get the whole isr w/timer interrupt, but how do you accurately vary the pulse widths in shift registers? I looked at the source, but the answer alluded me.

    here’s some links:
    product page: http://www.lynxmotion.com/Product.aspx?productID=395&CategoryID=52
    manual: http://www.lynxmotion.com/images/html/build136.htm
    source code: http://www.lynxmotion.com/images/html/proj078.htm

  5. The default arduino libraries are rather conservative, it their efforts not to turn an arduino in something that does lots of servos but not much else. I don’t see any reason why an AVR can’t support, say, 8 servos (sequentially, just as if they were at the end of a radio link) associated with EACH timer. I didn’t look at the lynxmotion firmware, but… You shift a 1 into your shift register, and it appears on output 0 connected to servo 0. Wait the desired pulse width (set the timer to interrupt, if you want.) Shift the existing 1 to the next output/servo, and wait the time associated with it. And so on. You might have minor glitches if servos on two separate shift registers happened to have their pulses expired at exactly the same time, but those would be on other order of microseconds long out of a millisecond pulse (and you could probably avoid them with clever code…)

  6. in older versions of the arduino ide, you were limited to two servos controlled via hardware PWM – one on pin 9 and one on pin 10. there’s been a software-servo library around for awhile that’s allowed you to control up to 20. since v. 0012(?) of the ide, software-servo has been integrated into the ide.

  7. The cool thing about the Roboduino board is that it has male headers and neighboring power busses, so you can literally just plug in servos and sensors and play.

    Experience : Have a roboduino

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s