25 lines
514 B
Plaintext
25 lines
514 B
Plaintext
' ########### start ###########
|
|
' pic:PIC16F886
|
|
' ########### end ###########
|
|
|
|
'pot_servo.gcb
|
|
'This program reads the potentiometer on AN0 and drives
|
|
'a small servo motor to a position based on the potentiometer
|
|
'position. Servo is connected to D8 (PORTB.0)
|
|
|
|
'Chip model
|
|
#chip 16f886, 16
|
|
|
|
main:
|
|
count = ReadAD(AN0)
|
|
if count < 75 then
|
|
count = 75 'Limit CW travel
|
|
end if
|
|
if count > 225 then
|
|
count = 225 'Limit CCW travel
|
|
end if
|
|
PulseOut D8,count 10us
|
|
Wait 20 ms
|
|
|
|
goto main
|