#include
#include “intrins.h“
typedef unsigned char uint8;
typedef unsigned int uint16;
sbit rs=P2^6; // 数据命令选择
sbit rw=P2^5; //读写选择
sbit e=P2^7; //使能
sbit k1=P3^3; //模式
sbit k2=P2^1; //加
sbit k3=P2^2; //减
sbit DHT11_DQ_OUT=P3^2;
sbit led1=P3^6;
sbit led2=P3^7;
sbit dq=P2^0;
uint8 mode=0xian;
char temph=50templ=20;
char humih=80humil=20;
uint8 temphumi;
uint8 flag; //设定报警标志
uint8 actempvalue;
uint8 code num[10]=“0123456789“;
uint8 code str1[]=“Temp:“; //温度
uint8 code str2[]=“Humi:“; //湿度
uint8 code str3[]=“Error“;
uint8 code str4[]=“Success “;
uint8 code str5[]=“%RH“;
uint8 code str6[]=“TempH:“; //设定温度上限显示
uint8 code str7[]=“TempL:“; //设定温度下限显示
uint8 code str8[]=“HumiH:“; //设定湿度上限显示
uint8 code str9[]=“HumiL:“; //设定湿度下限显示
void delay(uint16 i)
{
while(i--);
}
void delay_ms(uint16 i)
{
while(i--)
delay(90);
}
void wrc(uint8 c) //写命令
{
delay(1000);
rs=0;
rw=0;
e=0;
P0=c;
e=1;
评论
共有 条评论