Hi,
Try this one and read carefully the SERIN2, SEROUT2 section about the baudrate stuff. You will also foind a table in appendix A for the various baudrate values
Code:
@ __CONFIG _INTRC_OSC_NOCLKOUT & _MCLRE_ON & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON
TRISB = %11101011
CMCON = 7
Baud con 16780 ' 2400 bauds
Pre CON $A5
Synch CON "~"
In var byte
LOW PORTB.2 ' inverted mode normal idle state
pause 50
Main:
if (PORTB.1 = 0) then pressed
goto main
Pressed:
serout2 PORTB.2, baud, [Pre, Synch,"1"]
serin2 PORTB.3, baud, [WAIT(Synch),in]
if (in == "1") then
high PORTB.4
pause 250
low PORTB.4
pause 250
endif
goto main
Bookmarks