' Created Oct 9 2005 by Cory Forsyth ' reads in the values of two potentiometers and one switch. ' send the values out through serial to the computer ' works in tandem with a java application built with processing ' that moves a dot around on the screen like an etch a sketch. ' pressing the button ' clears the screen DEFINE OSC 4 INCLUDE "modedefs.bas" DEFINE ADC_BITS 10 DEFINE ADC_CLOCK 3 DEFINE ADC_SAMPLEUS 10 TRISA = %11111111 ' analog all input adcon1 = %10000010 ' right-justify analog result input portb.7 ' switch port switchPort var portb.7 serOutPort VAR portd.7 adcVar0 VAR WORD ' Create variable to store result adcVar1 VAR WORD ' Create variable to store result switchVar VAR BYTE switchVar = 0 pause 500 main: high portb.2 pause 500 low portb.2 pause 500 high portb.2 pause 500 low portb.2 ADCIN 0, adcVar0 ADCIN 1, adcVar1 if switchPort = 1 then switchVar = 1 high portb.2 else switchVar = 0 low portb.2 endif serout2 serOutPort, 16468, [DEC adcVar0,44,DEC adcVar1,44,DEC switchVar,13] ' serIN2 portc.7, 16468, [inputVar] PAUSE 20 GoTo main