' Define ADCIN parameters DEFINE OSC 4 start: Include "modedefs.bas" 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 TRISA = %11111111 ' Set PORTA to all input TRISB = %00000000 ADCON1 = %10000010 ' Set PORTA analog and right justify result Pause 500 ' Wait .5 second ADCvar VAR WORD ' Create variable to store result clear main: if adcvar <= 200 then high portb.7 else low portb.7 Endif if adcvar <= 400 then high portb.6 else low portb.6 endif if adcvar <= 600 then high portb.5 else low portb.5 Endif if adcvar <= 800 then high portb.4 else low portb.4 endif if adcvar <= 1000 then high portb.3 else low portb.3 Endif if adcvar <= 1019 then high portb.2 else low portb.2 endif ADCIN 0, ADCvar ' Read channel 0 to adval serout2 PORTC.6, 16468, [DEC ADCVar, 13, 10] ' print it to serial out, ' with linefeed and carriage return (10, 13) GoTo main ' Do it forever