51工业级单片机冰箱健康提醒系统

本文介绍了一个大一学生的初次实践项目——使用51单片机设计的冰箱健康提醒系统。该系统通过读取Ds18b20和DHT11传感器数据,监控并显示冰箱内的温度和湿度,同时设置警告阈值,当环境条件超出预设范围时发出警告。此外,系统还提供设置菜单,允许用户自定义温度和湿度的上下限。
摘要由CSDN通过智能技术生成

大一第一个项目,51初尝试
#include "reg52.h"    //´ËÎļþÖж¨ÒåÁ˵¥Æ¬»úµÄһЩÌØÊ⹦ÄܼĴæÆ÷
#include "lcd.h"
#include "temp.h"
#include "DHT11.h"

typedef unsigned int u16;   //¶ÔÊý¾ÝÀàÐͽøÐÐÉùÃ÷¶¨Òå
typedef unsigned char u8;


sbit set=P2^3; //ģʽ
sbit plus=P2^2; //¼Ó
sbit minus=P2^1; //¼õ
sbit search=P2^0; //²éѯ

sbit beep=P1^0; //·äÃùÆ÷
sbit H=P1^1;
sbit D=P1^2;

char tem;
char hum;
u16 mode;
char temph=30;
char templ=10;
char humih=80;
char humil=20;


void temperature(int temp)     //´¦ÀíζÈÊý¾Ý
{   float tp;
 if(temp< 0)    
   {
  temp=temp-1;
  temp=~temp;
  tp=temp;
  temp=tp*0.0625*100+0.5;
  temp=-temp; 
   }
  else
   {   
  tp=temp;
  temp=tp*0.0625*100+0.5; 
 }
 tem=temp/100;
}


void datapros1(int temp)  

    float tp;
 LcdShowStr(0,0," Temp ");
 if(temp< 0)    //µ±Î¶ÈֵΪ¸ºÊ
   {
  LcdWriteData('-');
 
  temp=temp-1;
  temp=~temp;
  tp=temp;
  temp=tp*0.0625*100+0.5; 

 
   }
  else
   {   
  LcdWriteData('+');
  tp=temp;
  
  temp=tp*0.0625*100+0.5; 
 }
 tem=temp;
 LcdWriteData(temp / 10000+'0');
 LcdWriteData(temp % 10000 / 1000+'0');
 LcdWriteData(temp % 1000 / 100+'0');
 LcdWriteData('.');
 LcdWriteData(temp % 100 / 10+'0');
 LcdWriteData(temp % 10+'0');
 LcdWriteData(0XDF);
 LcdWriteData('C');
 LcdWriteData(' ');
}

 

void num(u8 num)  

 u8 n;
 n=num;
 LcdWriteData(n/10+'0');
 LcdWriteData(n%10+'0');
}

void datapros2(u8 humi)  
{   
 LcdShowStr(0,1," Humi   ");
 num(humi);
 LcdWriteData(' ');
 LcdWriteData('%');
 LcdWriteData(' ');
 LcdWriteData(' ');
 LcdWriteData(' ');
 LcdWriteData(' ');
 LcdWriteData(' '

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值