By Sensor Workshop Class fall 2005

This PicBasic Pro code sends a word variable to an external computer serially. when it receives a single byte of value 65, it sends two bytes of a word variable, high byte (most significant byte) first.

It works well with the Processing Two Byte Receiver example.

' this is a sample to send a word variable to 
' an external computer.  when it receives a single byte
' of value 65, it sends two bytes of a word variable,
' high byte first.

' it uses a call-and-response method, waiting for a byte from 
' the external computer.

' by sensor workshop class 9/20/05


myVar var byte
sensorVar var word

sensorVar = 1023

main:   
    ' THE LISTENING CODE - puts message into inputVar
    serin2 portc.7, 16468, [myVar] 
    if myVar=65 then ' if received message is 65, then respond to processing
        ADCin 0, sensorVar
        'usage: serout2 dataPin, mode, [data]
        serout2 portc.6, 16468, [sensorVar.highbyte, sensorVar.lowbyte] 'talk to processing
    ENDiF
goto main