Programming: Making the Hobby Servo Turn the Horn Back and Forth using the PWM and OC1/PD5 Pin
The values are 800 (.8 ms) and 2200 (2.2 ms). These numbers can be further tweaked to turn the horn more towards its limits.
The OCR1A for the first position is moved into the while(1) never ending loop. A delay is introduced because it takes time for the servo to get to the intended position. If the delay was not used, the servo would just shake in a very small position. Also, since there is no way for the microcontroller to know the position of the servo (all of the closed loop positioning is internal within the servo) the delay allows the servo to reach the position.
Another OCR1A for the other extreme position is added after the delay. Another delay is added after this statement to give the servo time to get to this new position.
The process is repeated until the microcontroller is unplugged.
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.