Professional Documents
Culture Documents
Code
Code
int temp_c;
int temp;
char tempre[9] ;
void main()
{
TRISA = 0b00000010;
TRISC = 0x00 ;
PORTC = 0B00000111;
Lcd_Init() ;
Lcd_Cmd(_LCD_CURSOR_OFF) ;
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,2,"Welcome") ;
delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,2,"Temperature") ;
Lcd_Out(2,3,"project") ;
delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,2,"Designed by") ;
Lcd_Out(2,2,"Alaeldin hbib") ;
delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);
while(1)
{
Lcd_Out(1,1,"Temp now") ;
temp_c = Adc_Read(1) ;
temp =(temp_c*0.48876);
IntToStr(temp , tempre ) ;
Lcd_Out(2,1,tempre) ;
Lcd_Out_Cp(" ") ;
Lcd_Out(2,8,"celsius") ;
if (temp>=32)
{
PORTC = 0B10001001;
Lcd_Out(1,10," (hot)") ;
delay_ms(500);
}
if (temp<30 & temp>=20)
{
PORTC = 0B10000010;
Lcd_Out(1,10," (good)") ;
delay_ms(500);
}
if (temp<18)
{
PORTC = 0B00000100;
Lcd_Out(1,10," (Cool)") ;
delay_ms(500);
}
}
}