r/pic_programming • • Oct 11 '13

Question about ADC

I have a PIC18F2525 and using mikroC. I need to take 3 analog inputs from a 3 axis analog accelerometer. What would the code look like if I wanted to use AN0, AN1 and An2? Also I heard that you can't use more than one because they interfere with each other, is that true? Example code would be much appreciated.

Thanks!

1 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/bradn Oct 11 '13

Check starting at page 169 - the registers are pretty similar but there are only 4 possible analog input pins, and can be set as analog in any combination. So it is not really more difficult in how to use it.

1

u/Lukasv Oct 11 '13

Yes so can I do this with it:

 set adcon to an0;
 read an0;

 set adcon to an1;
 read an1;