void main()
{
int a= 4; char buf[30];
sprintf (buf, "Value is: %i",a);
unsigned int adc_value;
ANSEL = 0b00000001; // RA0/AN0 is analog input
ADCON0 = 0b10000000; // Analog channel select AN0
CMCON0 = 0x00000111 ; // Disable comparators
TRISC = 0b00000000; // PORTC All Outputs
TRISA = 0b00001001; // PORTA All Outputs, Except RA3 and RA0
ADCON1 = 0b00000000;
lcd_init();
lcd_goto(0); // select first line
lcd_puts("Weight Meas2:");
while(1) {
__delay_ms(100);
ADON = 1;
__delay_ms(100); // Wait the required acquisition time(2).
GO_DONE = 1;
__delay_ms(100); // Wait for ADC conversion
ADON = 0;
//Read ADC Result
unsigned int temp;
temp=ADRESH;
temp<<=8;
temp|=ADRESL;
sprintf (buf, "V: %04d", temp);
lcd_goto(0x40); // Select second line
lcd_puts(buf);
}
}