Tuesday, October 11, 2005

Servo!!!




start:
pulseWidth var byte ' set up constants with the minimum and maximum pulsewidths minPulse CON 50
maxPulse CON 250 ' set up a constant with the time between pulses:
refreshPeriod CON 20 ' set an initial pulsewidth:
pulseWidth = minPulse
main: 'take the output pin low so we can pulse it high
Low PORTb.2 ' pulse the pin
PulsOut PORTb.2, pulseWidth ' pause for as long as needed:
Pause refreshPeriod ' change the angle for the next time around:
IF pulseWidth > maxPulse Then
pulseWidth = minPulse
Else
pulseWidth = pulseWidth + 1
Endif
GoTo main

0 Comments:

Post a Comment

<< Home