
Originally Posted by
Forkosh
It worked!
But how would I change it to read AN0 and AN1
How do I change the program to read multiple channels?

Originally Posted by
Forkosh
which PICs work with the ADCIN command? WHich one that you used worked with that command?
Code:
ADCON0.1=1 ' Set GO/DONE bit to start A/D conversion
WHILE ADCON0.1=1 ' Wait for it to complete
WEND
adcVar.HighByte = ADRESH ' Read high-byte of result
adcVar.LowByte = ADRESL ' Read low-byte of result
Instead of the part above, you may try
ADCIN 0, AdcVar
and to continue with multiple channels, you may try
ADCIN 1, AdcVar1
ADCIN 2, AdcVar2
etc.
ADCIN command will take care of setting ADC registers etc.
Edit:
Here is another version of reading as many ADC channels as available on your PIC.
Code:
NumOfCh CON 7 ' Number of Analog Channels we will read.
' Change this number as desired.
AdcValue VAR BYTE[NumOfCh+1] ' Array to store ADC Values in a row.
Channel VAR BYTE ' Loop variable to go through channels.
Start:
FOR Channel = 0 TO NumOfCh ' Will read 7 analog cannnels and store
ADCIN Channel, AdcValue[Channel] '..ADC values in AdcValue Array.
Next Channel
' do something here.
GOTO Start
Bookmarks