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.
Comments and Additional Information
Have some code to share? Or additional information? Respond here:
You need to be logged in to save a response on this page. The response must be constructive, helpful, supplimentary or to correct the existing video, code or narrative content.