基于51单片机的12864显示温度(ds18b20)

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#ifndef __LCD12864_H

#define __LCD12864_H

//---包含头文件---//

#include

//---重定义关键词---//

#ifndef uchar

#define uchar unsigned char

#endif

#ifndef uint

#define uint unsigned int

#endif

//---如果使用画图模式定义这个---//

#define LCD12864_PICTURE

//---定义使用的IO口---//

#define LCD12864_DATAPORT P1 //数据IO口

sbit LCD12864_RS = P2^6; //(数据命令)寄存器选择输入sbit LCD12864_RW = P2^5; //液晶读/写控制

sbit LCD12864_EN = P2^7; //液晶使能控制

sbit LCD12864_PSB = P3^2; //串/并方式控制

sbit LCD12864_RST = P3^4; //复位端

//---声明全局函数---//

void LCD12864_Delay1ms(uint c);

uchar LCD12864_Busy(void);

void LCD12864_WriteCmd(uchar cmd);

void LCD12864_WriteData(uchar dat);

void LCD12864_Init();

void LCD12864_ClearScreen(void);

void LCD12864_SetWindow(uchar x, uchar y);

void LCD12864_DrowPic(uchar *a);

void LCD12864_DrowPoint(uchar x, uchar y);

#endif

#ifndef __TEMP_H_

#define __TEMP_H_

#include

//---重定义关键词---//

#ifndef uchar

#define uchar unsigned char

#endif

#ifndef uint

#define uint unsigned int

#endif

//--定义使用的IO口--//

sbit DSPORT=P3^3;

//--声明全局函数--//

void Delay1ms(uint );

uchar Ds18b20Init();

void Ds18b20WriteByte(uchar com);

uchar Ds18b20ReadByte();

void Ds18b20ChangTemp();

void Ds18b20ReadTempCom();

int Ds18b20ReadTemp();

#endif

#include"lcd12864.h"

/****************************************************************************** *

* 函数名: LCD12864_Delay1ms

* 函数功能: 延时1MS

* 输入: c

* 输出: 无

******************************************************************************* /

void LCD12864_Delay1ms(uint c)

uchar a,b;

for(; c>0; c--)

{

for(b=199; b>0; b--)

{

for(a=1; a>0; a--);

}

}

}

/****************************************************************************** *

* 函数名: LCD12864_Busy

* 函数功能: 检测LCD是否忙

* 输入: 无

* 输出: 1或0(1表示不忙,0表示忙)

******************************************************************************* /

uchar LCD12864_Busy(void)

{

uchar i = 0;

LCD12864_RS = 0; //选择命令

LCD12864_RW = 1; //选择读取

LCD12864_EN = 1;

LCD12864_Delay1ms(1);

while((LCD12864_DA TAPORT & 0x80) == 0x80) //检测读取到的值

{

i++;

if(i > 100)

{

LCD12864_EN = 0;

return 0; //超过等待时间返回0表示失败

}

}

LCD12864_EN = 0;

return 1;

}

相关文档
最新文档