' We are using a 20Mhz oscillator DEFINE OSC 20 TRISA = %00000000 'set all "A" ports to outputs TRISB = %00000000 'set all "B" ports to outputs ' We communicate with the XPort using 9600 8N1 serial true9600 con 84 timeOut con 50 ' the serial incoming timeout in milliseconds ' Our serial communication pins tx var PORTC.6 rx var PORTC.7 ' Our blinking pin for status messages statusPin var PORTC.4 OUTPUT statusPin ' Used to read response from the XPort inByte var byte ' Track whether or not we are connected to the remote server connected var bit connected = 0 Startup: ' Turn on our LED so we know that the startup sequence is going high statusPin ' Wait for the XPort to boot up pause 5000 ' Turn off the status LED while operating LOW statusPin ' Just so we know that we're ready, we'll quickly blink the status LED counter var byte counter = 0 while counter < 4 high statusPin pause 100 low statusPin pause 100 counter = counter + 1 wend main: gosub readabyte gosub checkInput goto main checkInput: if inbyte == "1" then HIGH portb.0 endif if inbyte == "2" Then LOW portb.0 endif if inbyte == "3" then high portb.1 endif if inbyte == "4" then LOW portb.1 endif Return readAByte: serin2 rx, true9600, timeOut, noData, [inByte] return noData: inByte = 0 return