这次的设计主要是通过读取DHT11和HCSR04的数值,(Proteus的传感器貌似这两款好用一点)把读取的DHT11和HCSR04数值通过转化在lcd1602中显示出来,还有就是可以设置通过按键设置DHT11的温湿度阈值。
仿真原理图如下
运行结果图:
按下K1,K2为加1设置,K3为减1设置
湿度低于88%;警报响,红灯亮
#include <stm32f4xx.h>
#include "delay.h"
#include "DHT11.h"
#include "LCD1602.h"
#include "SOUN.h"
#include "KEY_ExitInit.h"
#include "LED_INIT.h"
#include "HCSR04.h"
unsigned char move = 0x82;
unsigned char RH,RL,TH,TL;
unsigned char h0 = 0X38,h1 = 0X36;
unsigned char t0 = 0X32,t1 = 0X38;
unsigned char DATA[4];//存温湿度数据
unsigned char Leg[4];//存超声波
unsigned char R[7] = "SD:";
unsigned char H[7] = "WD:";
unsigned char L[7] = "Legth:";
unsigned char r[2] = "%";
unsigned char h[2] = "C";
// 读DHT11数据及数据转换 ///
int DHT11_ReadDATA(void)
{
int i;
省略。。
【资源下载】下载地址:点击下载(1648) 百度网盘