DS18b20與1602搭配,還帶高低溫(可調(diào))報警
#define uchar unsigned char
#define uint unsigned int
sbit DQ=P1^6;//ds18b20與單片機連接口
sbit RS=P1^0;
sbit RW=P1^1;
sbit EN=P1^2;
sbit BEEP=P1^7;
//unsigned char code str1[]={" "};
unsigned char code str2[]={" "};
uchardatadisdata[5];
uint tvalue;//溫度值
uchar tflag;//溫度正負標志
uchar hshi,hge,Th=25;
uchar Tl=20,lshi,lge;
sbit s1=P2^3; //功能
sbit s2=P2^2; //加
sbit s3=P2^1; //減
sbit gnd=P2^5;
uchar s1num;
/*************************lcd1602程序**************************/
void delay1ms(unsigned int ms)//延時1毫秒(不夠精確的)
{unsigned int i,j;
for(i=0;i
}
void wr_com(unsigned char com)//寫指令//
{ delay1ms(1);
RS=0;
RW=0;
EN=0;
P0=com;
delay1ms(1);
EN=1;
delay1ms(1);
EN=0;
}
void wr_dat(unsigned char dat)//寫數(shù)據(jù)//
{ delay1ms(1);;
RS=1;
RW=0;
EN=0;
P0=dat;
delay1ms(1);
EN=1;
delay1ms(1);
EN=0;
}
void lcd_init()//初始化設置//
{delay1ms(15);
wr_com(0x38);delay1ms(5);
wr_com(0x80);delay1ms(5);
wr_com(0x01);delay1ms(5);
wr_com(0x06);delay1ms(5);
wr_com(0x0c);delay1ms(5);
}
void display(unsigned char *p)//顯示//
{
while(*p!=