imaasac
Newbie level 6
Hi guyz!
I am trying to interface lm35 sensor with PIC microcontroller and light the LED when temperature goes beyond 40 deg Celsius. I am using 16F877a pic and using compiler PICC in C language. I have done simulation on Proteus and got no results. I have write this code, can any body tell me where is the problem in this code. Thanks
I am trying to interface lm35 sensor with PIC microcontroller and light the LED when temperature goes beyond 40 deg Celsius. I am using 16F877a pic and using compiler PICC in C language. I have done simulation on Proteus and got no results. I have write this code, can any body tell me where is the problem in this code. Thanks
Code:
#use delay(clock=10000000)
int16 temp, cent;
int16 triptemp, triptempc=40;
void main()
{
setup_adc_ports(all_ANALOG);
setup_adc(ADC_clock_internal);
set_adc_channel(0);
TripTemp = ((TripTempC/1023)*500);
while(1)
{
temp=read_adc();
cent=((temp/1023)*500);
if(cent>triptemp)
{
output_high(53);
}
else
{
output_low(53);
}
delay_ms(100);
}
}