You are on page 1of 2

sbit LCD_RS at RB2_bit;

sbit LCD_EN at RB3_bit;


sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB2_bit;


sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;

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);
}
}
}

You might also like