Monday, July 11, 2005

Servo Motor Pulse-Width var




'set servoMotor into RC3
'OSC=Oscillator 4MHZ
DEFINE OSC 4

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 PORTC.3
' pulse the pin
PulsOut PORTC.3, 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