sir can you please check what's wrong with my code?
the problem is i can't get the actual temperature.. for example The value of my LM35 is 31.0C in ISIS, but the output in virtual terminal is 31.2C..
27.0 c = 27.3 c
27.1 c = 27.3 c
27.2 c = 27.3 c
27.3 c = 27.3 c
27.4 c = 27.3 c
27.5 c = 27.8 c
void main() {
float temp,AdcTemp;
int IntegTemp1, IntegTemp2,DeciTemp;
ADCON2 = 0x82; // Configure analog inputs and Vref
TRISA = 0xFF; // PORTA is input
TRISB = 0x3F; // Pins RB7, RB6 are outputs
TRISD = 0; // PORTD is output
usart_init(9600);
delay_ms(500);
do {
AdcTemp= Adc_Read(2);
Temp = (AdcTemp*5000)/1023;
IntegTemp1 = (int) Temp*.01;
IntegTemp2 = (int) Temp*.1 - (IntegTemp1*10);
DeciTemp = (int) Temp*1 - (IntegTemp1*100+(IntegTemp2*10));
usart_write('T');
usart_write('E');
usart_write('M');
usart_write('P');
usart_write('=');
usart_write(IntegTemp1+48);
usart_write(IntegTemp2+48);
usart_write('.');
usart_write(DeciTemp+48);
usart_write(' ');
usart_write('C');
usart_write(13);
usart_write(10);
delay_ms(400);
} while(1);
}
the problem actually is the "DeciTemp". Please help sir.