sábado, 29 de setembro de 2012

ROBÔ VIA RF
TX:
 include "modedefs.bas"
 @ DEVICE pic16F628A
 @ DEVICE pic16F628A, WDT_OFF
 @ DEVICE pic16F628A, PWRT_OFF
 @ DEVICE pic16F628A, BOD_OFF
 @ DEVICE pic16F628A, PROTECT_OFF
 @ DEVICE pic16F628A, MCLR_OFF
 @ DEVICE pic16F628A, INTRC_OSC_NOCLKOUT
DEFINE OCS 4
TRISA=%11111111
PORTA=0
TRISB=%11111110
PORTB=0
CMCON=7
B0 VAR BYTE
B1 VAR BYTE
B0 = 0
B1 = 0

PROG:
POT PORTA.0,255,B0
POT PORTA.1,255,B1
IF B0>100 THEN FRE
IF B0<60  THEN TRA
IF B1>100 THEN ESQ
IF B1<60  THEN DIR
SEROUT PORTB.0,n9600,["E"] 'PARA TUDO
GOTO PROG

FRE:
SEROUT PORTB.0,n9600,["A"]
GOTO PROG

TRA:
SEROUT PORTB.0,n9600,["B"]
GOTO PROG

ESQ:
SEROUT PORTB.0,n9600,["C"]
GOTO PROG

DIR:
SEROUT  PORTB.0,n9600,["D"]
GOTO PROG
END

RX:

include "modedefs.bas"
 @ DEVICE pic16F628A
 @ DEVICE pic16F628A, WDT_OFF
 @ DEVICE pic16F628A, PWRT_OFF
 @ DEVICE pic16F628A, BOD_OFF
 @ DEVICE pic16F628A, PROTECT_OFF
 @ DEVICE pic16F628A, MCLR_OFF
 @ DEVICE pic16F628A, INTRC_OSC_NOCLKOUT
DEFINE OCS 4
TRISA=%11111111
PORTA=0
TRISB=000001
PORTB=0
CMCON=7
B0 VAR BYTE

PROG:
serin PORTB.0,n9600,B0
if B0 = "A" then FRE
if B0 = "B" then TRA
if B0 = "C" then ESQ
if B0 = "D" then DIR
if B0 = "E" then PARA
GOTO  PROG

FRE:
PORTB=%01010000
GOTO  PROG

TRA:
PORTB=%10100000
GOTO PROG

ESQ:
PORTB=%01100000
goto PROG

DIR:
PORTB=%10010000
GOTO  PROG

PARA:
PORTB=00000000
GOTO PROG
END