@ DEVICE PIC16F876A
@ DEVICE PIC16F876A,WDT_OFF
@ DEVICE PIC16F876A,PWRT_OFF
@ DEVICE PIC16F876A,PROTECT_OFF
@ DEVICE PIC16F876A,XT_OSC
define OCS 4
ADCON1 = 7
TRISC=%10000000:PORTC=%10000000
TRISA=%11111111:PORTA=%11111111
TRISB=%00000000:PORTB=%00000000
SYMBOL SERVO1=PORTB.0 'SERVO1
SYMBOL RX_INP=PORTC.7 'RF
RX VAR BYTE
POS VAR word
POS = 1500
PROG:
serin2 RX_inp,84,600,MODATA,[wait("PC"),RX,DEC POS]
SELECT CASE RX
CASE 65 'A
GOSUB FRE
CASE 66 'B
GOSUB TRA
CASE 67 'C
GOSUB DIR
CASE 68 'D
GOSUB ESQ
CASE 69 'E
HIGH PORTB.0
pauseus 1500 + pos
LOW PORTB.0
Pause 20
END SELECT
GOTO PROG
FRE:
PORTC.0 = 0
PORTC.1 = 1
PORTC.2 = 1
PORTC.3 = 0
RETURN
TRA:
PORTC.0 = 1
PORTC.1 = 0
PORTC.2 = 0
PORTC.3 = 1
RETURN
ESQ:
PORTC.0 = 1
PORTC.1 = 0
PORTC.2 = 1
PORTC.3 = 0
RETURN
DIR:
PORTC.0 = 0
PORTC.1 = 1
PORTC.2 = 0
PORTC.3 = 1
RETURN
MODATA:
PORTC.0 = 0
PORTC.1 = 0
PORTC.2 = 0
PORTC.3 = 0
GOTO PROG
Bookmarks