标题:
单片机LCD显示温度日期时间(触摸DS18B20温度产生变化)
[打印本页]
作者:
hsa18508776863
时间:
2025-6-16 17:44
标题:
单片机LCD显示温度日期时间(触摸DS18B20温度产生变化)
这是在课上要求做的“LCD显示温度日期时间(触摸DS18B20温度产生变化)”,文件中包含程序源代码工程文件和DS18B20的详细介绍
#include "pbdata.h"
#define LCD_DB P0
sbit LCD_EN=P2^7;
sbit LCD_RS=P2^6;
sbit LCD_RW=P2^5;
unsigned char code cg_1602[]={ 0x08,0x0f,0x12,0x0f,0x0a,0x1f,0x02,0x02,
0x0f,0x09,0x0f,0x09,0x0f,0x09,0x11,0x00,
0x0f,0x09,0x09,0x0f,0x09,0x09,0x0f,0x00};//"ÄêÔÂÈÕ"
void LCDBusy()
{
unsigned char busy;
LCD_DB=0xff;
LCD_RS=0;
LCD_RW=1;
do
{
LCD_EN=1;
busy=LCD_DB;
LCD_EN=0;
}while(busy & 0x80);
}
void LCDWriteCmd(unsigned char cmd)
{
//LCDBusy();
LCD_RW=0;
LCD_RS=0;
LCD_EN=1;
LCD_DB=cmd;
LCD_EN=0;
delay_1ms(1);
}
void LCDWriteData(unsigned char dat)
{
//LCDBusy();
LCD_RW=0;
LCD_RS=1;
LCD_EN=1;
LCD_DB=dat;
LCD_EN=0;
delay_1ms(1);
}
void LCDInit()
{
LCDWriteCmd(0x38);
delay_1ms(10);
LCDWriteCmd(0x0c);
delay_1ms(10);
LCDWriteCmd(0x06);
delay_1ms(10);
LCDWriteCmd(0x01);
delay_1ms(10);
}
void LCDSetCursor(unsigned char x,unsigned char y)
{
unsigned char addr;
if(y==0)
addr=0x00+x;
else
addr=0x40+x;
LCDWriteCmd(addr | 0x80 );
}
void LCDDisp(unsigned char x,unsigned char y,unsigned char *str)
{
LCDSetCursor(x,y);
while(*str!='\0')
{
LCDWriteData(*str++);
}
}
void LCDDisp_char(unsigned char x,unsigned char y,unsigned char dat)
{
//LCDInit();
LCDSetCursor(x,y);
LCDWriteData(dat);
}
void write_cg()//дÈë¹Ì¶¨ºº×ֺͷûºÅ
{
unsigned char num;
LCDWriteCmd(0x40); //É趨CGRAMµØÖ·
for(num=0;num<24;num++) //½«×Ô¶¨Òå×ÖÐÍÂëдÈëCGRAMÖÐ
{
LCDWriteData(cg_1602[num]);
}
LCDWriteCmd(0x84);//Äê
{
LCDWriteData(0);
}
LCDWriteCmd(0x87);//ÔÂ
{
LCDWriteData(1);
}
LCDWriteCmd(0x8a);//ÈÕ
{
LCDWriteData(2);
}
LCDDisp(2,1,":");
LCDDisp(5,1,":");
}
复制代码
原理图: 无
仿真: 无
代码: Keil程序:
LCD显示温度日期时间(自己程序).zip
(130.76 KB, 下载次数: 0)
2025-6-16 17:44 上传
点击文件名下载附件
下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1