' {$STAMP BS2} ' {$PBASIC 2.5} X VAR Byte CHANNEL CON $0C 'channel BAUD CON 84 ' Baud rate, 9600, 8-N-1, non-inverted, on BS2. RX PIN 0 ' Receive Pin TX PIN 2 ' Transmit Pin GOSUB EstablishConnection DO x = IN1 ' Sense input pin #1 and store a "0" or "1" in variable x DEBUG "x=" ' Print out "x=" DEBUG DEC1 X, CR ' Print out x SEROUT TX, BAUD, [DEC X, CR, CR] ' Send value of X as decimal to receiver Boe-Bot ' Second CR is added byte buffer for flow control example PAUSE 20 LOOP END EstablishConnection: HIGH TX DEBUG CLS, "Configuring XBee..." PAUSE 2000 ' Guard time for command sequence SEROUT TX, BAUD,["+++"] ' Enter command mode PAUSE 2000 ' Guard time for command sequence SEROUT TX, BAUD, ["ATCH ", HEX CHANNEL, CR] ' Set channel PAUSE 2000 DEBUG "Configuration Complete!",CR RETURN