CONTROLE DE DIREÇÃO USANDO O COMANDO POT EM PICBASIC PRO
TX:
include "modedefs.bas"
DEFINE OSC 4
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 5
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 4
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
CMCON=7
TRISB=0
PORTB=0
TRISA=0
PORTA=0
LCDOUT $fe,1, " By Cesar"
pause 1000
DADOS VAR BYTE
PROG:
POT PORTA.0,255,DADOS
DADOS=DADOS*2
LCDOUT$FE, 1," DADOS = "
LCDOUT, #DADOS
PAUSE 1000
IF DADOS>95 THEN
SEROUT PORTA.2,N2400,["A"]
ELSE
SEROUT PORTA.2,N2400,["E"]
IF DADOS<30 THEN
SEROUT PORTA.2,N2400,["B"]
ELSE
SEROUT PORTA.2,N2400,["E"]
ENDIF
ENDIF
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,n2400,B0
if B0 = "A" then FRE
if B0 = "B" then TRA
if B0 = "E" then PARA
goto PROG
FRE:
PORTB=%01010000
goto PROG
TRA:
PORTB=%10100000
goto PROG
PARA:
PORTB=0
GOTO PROG
end