AT89C52控制溫度傳感器DS18B20并在LM016L_LCD上顯示
//--------------------------------------------------------
本文引用地址:http://m.butianyuan.cn/article/201807/383597.htm//文 件 名:Temperture_Control
//
//文件簡(jiǎn)介:AT89C52作為主控,實(shí)時(shí)獲取、處理、發(fā)送數(shù)據(jù),全局控制;
//DS18B20_Sensor溫度(-50 ~ 255℃)數(shù)據(jù)實(shí)時(shí)輸入;
//LM016L_LCD溫度數(shù)據(jù)實(shí)時(shí)顯示
//
//修改時(shí)間:2017.10.24
//
//修改人員:Touch
//--------------------------------------------------------
#includereg52.h
//宏定義、全局變量定義區(qū)
#defineuchar unsigned char
#define uint unsigned int
uchar code disp[]=0123456789;//數(shù)據(jù)顯示數(shù)組
uchar code disp2[]=Tempreture;//標(biāo)題欄顯示
uchar code disp3[]=^C; //單位顯示
//LCD管腳位定義
sbit lcden=P2^0;
sbit lcdrw=P2^1;
sbit lcdrs=P2^2;
sbit tempt=P2^3;
uint u_temp;//定義無(wú)符號(hào)整型形參
float f_temp;//定義浮點(diǎn)型形參
//----------------------------------------
//函 數(shù) 名:delay()
//函數(shù)類(lèi)型:void
//入口參數(shù):unint x
//出口參數(shù):None
//說(shuō)明:?jiǎn)纹瑱C(jī)指令周期為---計(jì)算延時(shí)、//延時(shí)500ms程序
//----------------------------------------
void delay(uint x)
{
uint i,j;
for(i=0;i
for(j=0;j130;j++);
}
//----------------------------------------
//函 數(shù) 名:write_com
//函數(shù)類(lèi)型:void
//入口參數(shù):uchar com
//出口參數(shù):None
//說(shuō)明:液晶寫(xiě)命令函數(shù)
//----------------------------------------
void write_com(uchar com)
{
lcdrs=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
delay(5);
}
//----------------------------------------
//函 數(shù) 名:write_data
//函數(shù)類(lèi)型:void
//入口參數(shù):uchar date
//出口參數(shù):None
//說(shuō)明:液晶寫(xiě)數(shù)據(jù)函數(shù)
//----------------------------------------
void write_data(uchar date)
{
lcdrs=1;
P0=date;
delay(5);
lcden=1;
delay(5);
評(píng)論