Pressure Sensor Code from Tom Igoe example
' Define ADCIN parameters
' Set number of bits in result
DEFINE ADC_BITS 10
' Set clock source (3=rc)
DEFINE ADC_CLOCK 3
' Set sampling time in microseconds
DEFINE ADC_SAMPLEUS 10
' serial constants and pin assignments: tx var portc.6 rx var portc.7 n9600 con 16468
adcVar VAR WORD ' Create variable to store result adcvar2 var word result var word
' Set PORTA to all input TRISA = %11111111
' Set up ADCON1? ADCON1? = %10000010
Pause 500 ' Wait .5 second
main:
ADCIN 0, adcVar ' Read channel 0 pause 10 ' let the ADC settle adcin 1, adcvar2 ' read channel 1 ' get the difference between the two: result = abs(adcvar - adcvar2) ' send out the result SEROUT2? tx, n9600, [DEC result, 10, 13] Pause 10 ' let the ADC settle
