Datasheet
Programming PIC Microcontrollers in BASIC - mikroElektronika
Potentiometer gives 0V in one terminal position and 5V in the other – since we use 8-bit conversion, our digitalized
voltage can have 256 steps. The following program reads voltage on RA0 pin and displays it on port B diodes. If not one
diode is on, result is zero and if all of diodes are on, result is 255.
program ADC_8
main:
TRISA = %111111 ' Port A is input
PORTD = 0
TRISD = %00000000
ADCON1 = %1000010 ' Port A is in analog mode,
' 0 and 5V are referent voltage values,
' and the result is aligned right
' (higher 6 bits of ADRESH are zero).
ADCON0 = %11010001 ' ADC clock is generated by internal RC
http://www.mikroelektronika.co.yu/english/product/books/picbasicbook/06.htm (4 sur 12)05/11/2004 02:26:24