'**************************************************************** '* Name : UNTITLED.BAS * '* Author : VINCENT DEAN BOYCE * '* Notice : Copyright (c) 2006 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 2/26/2006 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** ' call and response serial example for picBasic Pro. ' By Tom Igoe, 2003 ' updated 25 Oct. 2005 ' This example waits for a byte on the incoming serial connection, ' It then sends the value of a sensor on RA0, as a two-byte value. ' serial RX is on pin RC7 ' serial TX is on pin RC6 ' Define ADCIN parameters DEFINE ADC_BITS 10 ' Set number of bits in result DEFINE ADC_CLOCK 3 ' Set clock source (3=rc) DEFINE ADC_SAMPLEUS 50 ' Set sampling time in uS ' constant to set the baud rate: inv9600 con 16468 ' define variables: adcVar var word inByte var byte TRISA = %11111111 ' Set PORTA to all input ADCON1 = %10000010 ' Set PORTA analog and right justify result main: ' read sensors, convert to bytes: adcin 0, adcVar ' read serial data in: serin2 portc.7, inv9600, [inByte] ' if you got the message from the remote device, send out data: serout2 portc.6, inv9600, [adcVar.lowByte, adcVar.highByte] goto main