On Paper: How to Output a PWM (Pulse Width Modulation) Signal on Any Pin of the Microcontroller

In this case, a Hitec hobby servo is controlled using the PWM signal, but any device could be controlled using this method with a change to the ICR value to conform to the device's PWM frequency requirement. The 19,999 (20,000 indexed from 0) is used because this translates to a 50 Hz frequency, or 20 ms period that the Hitec servo requires. The TCNT1 will be used to bring the pin low within the period for the specific pin. The TCNT1 is a timer/counter that holds the value of the clock.



Back to blog

Leave a comment

Please note, comments need to be approved before they are published.