AT89C52控制溫度傳感器DS18B20并在LM016L_LCD上顯示
//--------------------------------------------------------
本文引用地址:http://cafeforensic.com/article/201807/383597.htm//文 件 名:Temperture_Control
//
//文件簡介:AT89C52作為主控,實時獲取、處理、發(fā)送數(shù)據(jù),全局控制;
//DS18B20_Sensor溫度(-50 ~ 255℃)數(shù)據(jù)實時輸入;
//LM016L_LCD溫度數(shù)據(jù)實時顯示
//
//修改時間: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;//定義無符號整型形參
float f_temp;//定義浮點型形參
//----------------------------------------
//函 數(shù) 名:delay()
//函數(shù)類型:void
//入口參數(shù):unint x
//出口參數(shù):None
//說明:單片機指令周期為---計算延時、//延時500ms程序
//----------------------------------------
void delay(uint x)
{
uint i,j;
for(i=0;i
for(j=0;j130;j++);
}
//----------------------------------------
//函 數(shù) 名:write_com
//函數(shù)類型:void
//入口參數(shù):uchar com
//出口參數(shù):None
//說明:液晶寫命令函數(shù)
//----------------------------------------
void write_com(uchar com)
{
lcdrs=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
delay(5);
}
//----------------------------------------
//函 數(shù) 名:write_data
//函數(shù)類型:void
//入口參數(shù):uchar date
//出口參數(shù):None
//說明:液晶寫數(shù)據(jù)函數(shù)
//----------------------------------------
void write_data(uchar date)
{
lcdrs=1;
P0=date;
delay(5);
lcden=1;
delay(5);
評論