Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

sbit LCD_RS at RC2_bit;

sbit LCD_EN at RC3_bit;


sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;

sbit LCD_RS_Direction at TRISC2_bit;


sbit LCD_EN_Direction at TRISC3_bit;
sbit LCD_D4_Direction at TRISC4_bit;
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D6_Direction at TRISC6_bit;
sbit LCD_D7_Direction at TRISC7_bit;

void main() {
unsigned int i,ADC, newout, prevout;
char stoutput[7];
TRISD=0;
ADCON1=0b00001111;
lcd_Init();
lcd_Cmd (_LCD_CURSOR_OFF) ;
while(1)
{
ADC=ADC_read(0);
newout=(1.5/1023)*ADC*100;
if(newout!=prevout){
lcd_Cmd(_LCD_CLEAR);
inttostr(newout,stoutput);
lcd_out(2,1,"temp:");
lcd_out(2,10,stoutput);
if(newout<10)
{
lcd_out(1,1,"bit chillay!");
for(i=0;i<3;i++)
{
latd=0b00001000;
delay_ms(130);
latd=0b00000100;
delay_ms(130);
latd=0b00000010;
delay_ms(130);
latd=0b00000001;
delay_ms(130);
}
if(newout>=10 && newout<30)
{
lcd_out(1,1,"Nice weather!");
for(i=0;i<7;i++)
{
latd=0b00001000;
delay_ms(100);

latd=0b00000100;
delay_ms(100);
latd=0b00000010;
delay_ms(100);
latd=0b00000001;
delay_ms(100);
}
}
if(newout=30)
{
lcd_out (1,1,"im boiling!");
for(i=0;i<7;i++)
{
latd=0b00001000;
delay_ms(70);
latd=0b00000100;
delay_ms(70);
latd=0b00000010;
delay_ms(70);
latd=0b00000001;
delay_ms(70);}
}
prevout=newout; } }
}

You might also like