新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > DS18b20與1602搭配,還帶高低溫(可調(diào))報警

DS18b20與1602搭配,還帶高低溫(可調(diào))報警

作者: 時間:2016-12-02 來源:網(wǎng)絡 收藏
#include

#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;

本文引用地址:http://m.butianyuan.cn/article/201612/324682.htm

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 for(j=0;j<100;j++);
}

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!=