unsigned int temp_res;
char buf2[6];
int i;
void main() {
UART1_Init(9600);
ADCON1 = 0x80;
ADCON0=0xC1;
TRISA = 0xFF;
ANSEL = 0xFF; // Configure AN2 pin as analog
//ANSELH = 0; // Configure other AN pins as digital I/O
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
TRISA = 0xFF; // PORTA is input
TRISC = 0; // PORTC is output
TRISB = 0; // PORTB is output
do {
temp_res = ADC_Read(0); // Get 10-bit results of AD conversion
PORTB = temp_res; // Send lower 8 bits to PORTB
PORTC = temp_res >> 8; // Send 2 most significant bits to RC1, RC0
wordToStr(temp_res,buf2);
for(i = 0; i < 6; i++)
{
UART1_Write(buf2[i]);
Delay_ms(80);
}} while(1);
}