Small demo code to control a servo motor using an attiny13 microcontroller.
With Fast PWM Mode, the PWM frequency is set by the prescaler value (on an attiny13), so I could only get close to the "standard" 50Hz.
The program sets it to 73Hz which is totally fine (servo motors can be controlled by a PWM frequency ranging from 40Hz to 200Hz according to wikipedia)
The pulse width is controlled by a potentiometer.
attiny13 pin | Connection |
---|---|
PB0 | Servo Signal |
PB4 | Potentiometer |