一、简介
此系统主要由AT89C51、多个DS18B20温度模块和LCD1602组成。
大致的原理是多个DS18B20按顺序采集温度到的数据传送给AT89C51的P2.7,最后通过LCD1602显示当前的实时温度,按键可以设置上下限温度,根据温度判断是否需要报警。
二、运行效果图
模拟仿真运行
三、部分代码
/*想要更多项目私wo!!!*/
#include #include unsigned int iTempDataH; unsigned int SetTemp = 30; int SetTemp1 = 1; int num = 0; //ÅжÏæָÁî void Busy() { DATA = 0xff; RS = 0; RW = 1; while(DATA & 0x80) { E = 0; E = 1; } E = 0; } //дָÁî³ÌÐò void WriteCommand(unsigned char btCommand) { Busy(); RS = 0; RW = 0; E = 1; DATA = btCommand; E = 0; } //дÊý¾Ý³ÌÐò void WriteData(unsigned char btData) { Busy(); RS = 1; RW = 0; E = 1; DATA = btData; E = 0; } //ÇåÆÁÏÔʾ void Clear() { WriteCommand(1); } //³õʼ»¯ void Init() { WriteCommand(0x0c); //¿ªÏÔʾ,ÎÞ¹â±êÏÔʾ WriteCommand(0x06); //ÎÄ×Ö²»¶¯£¬¹â±ê×Ô¶¯ÓÒÒÆ WriteCommand(0x38); //ÉèÖÃÏÔʾģʽ:8λ2ÐÐ5x7µãÕó } //ÏÔʾµ¥¸ö×Ö·û void DisplayOne(bit bRow, unsigned char btColumn, unsigned char btData, bit bIsNumber) { if (bRow) WriteCommand(0xc0 + btColumn); else WriteCommand(0x80 + btColumn); if (bIsNumber) WriteData(btData + 0x30); else WriteData(btData); } //ÏÔʾ×Ö·û´®º¯Êý void DisplayString(bit bRow, unsigned char btColumn, unsigned char *pData) { while (*pData != '