PIC Code

define OSC 4
' 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

ADCvar VAR WORD ' Create variable to store result
inByte var byte

input porta.0
ADCON1 = %10000010 ' Set PORTA analog and right justify result

Pause 500 ' Wait .5 second
main:

	ADCIN 0, ADCvar       ' Read channel 0 to adval
	serin2 PORTC.7, 16468, [inbyte]
    serout2 PORTC.6, 16468, [adcvar.lowbyte, adcvar.highbyte] 
    'serout2 PORTC.6, 16468, [dec inbyte]

GoTo main

Back