Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is my first time asking a question on this website, so please correct me if I'm doing something wrong...

I have been working on a small project which runs three Servo motors on an ATtiny85, using C on Code::Blocks on a Mac.

So far, I have accomplished to move two Servos using PWM on PB1 and PB4. PB1 is controlled by TCCR1 which is connected to OCR1A, and PB4 is controlled by GTCCR which connected to OCR1B. After reading the data sheet, I thought I could run one more on PB0, which is controlled by TCCR0A, but I cannot figure out which register to use to connect to servo (e.g. OCR1D).

So, my question is... Can I run three servos on an ATtiny85? If so, what is the register for the third servo?

share|improve this question
The term "servo" can stand for 2 different things. (1) Remote controller (r/c) servo, like the ones found in r/c airplanes, cars, models, etc. These are self-contained devices, which roll a motor, motor driver, feedback sensor, control loop into a one little handy package. (2) Industrial servo motors. More complex. Motor, feedback sensor, and control loop are separate. Which meaning of the word "servo" do you have in mind for this question? – Nick Alexeev Mar 1 '14 at 23:56
Depending on your setup or needs, you could run hundreds. If they have the same frequency and just need a different duty cycle, a single timer with some software control of pins can control many. – Passerby Mar 2 '14 at 1:11

Below is the pinout for the ATtiny85:

enter image description here

You said you are already using PB1 and PB4, so you must be using Timer1 to drive these PWM pins, using the pins as: OC1A and OC1B.

It appears you also have PB0 driven by Timer0 as pin: OC0A. It would also seem you are capable of controlling 3 PWM pins independently with the ATtiny85 (PB3 is just the NOT of PB4).

Simply set these registers for Timer0 in a similar fashion as you have with Timer1.

I've included the datasheet here: ATtiny85

share|improve this answer

You can run 4 servos: 3 with hardware, 1 with software with hardware assist.

Using OC0A, OC1A, and OC1B gives you three hardware PWM channels via OCR0A, OCR1A, and OCR1B.

You can use OCR0B for a fourth software channel, using the OCR0B compare (TIM0_COMPB_vect) and timer 0 overflow (TIM0_OVF_vect) interrupts to toggle one of the other pins appropriately. Just make sure that the timing from ISR start to actual toggle is equal for both ISRs so that your results are accurate.

Since you will have 2 pins left over it may be possible to use 2 more servos under full software control, but without any hardware support you will be at the mercy of the rest of your code. Consider using a larger device if you need more than 4 PWM channels.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.