Let's Make Robots!

ATtiny84 3-servo hexapod

Avoids obstacles

Similar to the Pololu 3-servo hexapod, except I made my own PCB, built my own IR sensor system, and wrote my own code including hardware Timer1/interrupt assisted servo pulse control.

Code and PCB layout here:


Comment viewing options

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


 My email is kpking2002@gmail.com.

It is also a very bad idea to post your email address anywhere online.  Your profile has an option to enable other members to contact you.  That is much safer.


 Could you send me the code(if you used C++) and the instructions to build?


There are multiple links to the code in the post.

It's bad form to ask for code not offered.

Download here:


Feedback welcome.

I would be one of those fans. I figured I'd be able to get 4 servos working across the tiny family but shelved the project some time ago. I was aiming at using an 8-bit timer though, so this looks promising.

If you could turn your TCCR code into a library for the Tinies that actually worked on servos you'd have an eternally grateful fanbase. Good looking bot!

Well in the meantime there's some example Tiny servo code here that can you can paste into your sketch:


But I'd certainly consider turning it into a library. While I'm at it, I should probably upgrade the resolution though (right now just 56 steps). I think I can bump that to about 224 steps and still allow 8 servos to be controlled.

Note that I use a 16-bit timer, which is not available on ATtiny85. It appears that in addition to the ATtiny84, the ATtiny2313 has a 16-bit timer so it "should" work there too. Do you have a particular Tiny in mind? I might be able to use an 8-bit timer, have to run the numbers to see how hard it would be...

Those are the most popular it seems like, though I have 44/84 and 2313 in the collection too.  It seems like there's a tipping point to the number of pins that a project needs before it becomes economical to just put a regular mega(xx)8 on it.  JerZ and I have been boxing with the cunning turtle library and I don't think any of us believes it does what it claims to.  I looked over your code and am impressed (by anyone who learns to use hardware timers, in fact.)  This is just programming the tiny via the Arduino as ISP, right?  Anyway, good work and thanks for contributing!

Yes I use Arduino as ISP to program my Tinies. The Burn Bootloader function is used to set the fuses to 8MHz etc.

Yeah I looked at the Cunning Turtle Servo8Bit library after I had commited to the ATtiny84, but when I saw many reports of people having problems with it I decided it was time (ha!) to learn timers myself. I see now that the SoftwareServo library (http://playground.arduino.cc/ComponentLib/Servo) also claims to support the Tinies, but you have to call refresh() every 50ms in your loop and it has a "slight position distortion in the [servos] with the lowest angular values."

I'm sure the Cunning and SoftwareSerial authors know what they're doing but I see they are both C++ to maintain compatibility with the stock Servo lib. Call me old-fashioned, but I prefer to stick with pure C when possible, especially since Flash and RAM are so limited on an ATtiny. (Yes, libraries can be done in pure C.) Hopefully by keeping things small/simple I will end up with something robust.

So I've been running the numbers on using an 8-bit timer. It looks feasible, so I can probably support the entire ATtiny range including 45/85. If my math is right, ~225 steps from 0° to 180° at 50Hz with up to 8 servos on an 8MHz chip should be possible.