一:功能介绍
1、采用stm32单片机+LCD1602+DHT11温湿度传感器+按键+电机,制作一个单片机高低温恒温恒湿试验箱自动控制系统;
2、通过按键设置温度和湿度的阈值,通过DHT11传感器采集温湿度;
3、当采集温度大于阈值,开启制冷模式,当温度小于设置温度,开启加热模式,当采集湿度大于阈值,开启排气模式,当湿度小于设置湿度,开启加湿模式;
4、LCD1602显示实时温湿度和按键设置的温湿度阈值;
二:仿真演示视频+程序简要讲解:(程序有中文注释,新手容易看懂)
111-基于stm32单片机高低温恒温恒湿试验箱自动控制系统Proteus仿真+程序源码+讲解视频
三:设计软件介绍
本设计使用C语言编程设计,程序代码采用keil5编写,程序有中文注释,新手容易看懂,仿真采用Proteus软件进行仿真,演示视频使用的是Proteus8.9版本;资料包里有相关软件包,可自行下载安装。
四:程序打开方法
特别注意:下载资料包以后一定要先解压!!!(建议解压到桌面上,文件路径太深会导致程序打开异常),解压后再用keil5打开。
程序部分展示,有中文注释,新手容易看懂
/*****************引脚配置********************/
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
//LCD1602 管脚
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8| GPIO_Pin_9| GPIO_Pin_10| GPIO_Pin_11| GPIO_Pin_12| GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
GPIO_Init(GPIOB, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 |GPIO_Pin_6|GPIO_Pin_5;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
//DHT11
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
void IO_out( void )
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOC ,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0| GPIO_Pin_1| GPIO_Pin_2| GPIO_Pin_3;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10|GPIO_Pin_9|GPIO_Pin_8|GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure);
PCout(7)=PCout(8)=PCout(9)=PCout(10)=1;
}
void anjiansaomiao(void)
{
//温度值+
if(k1 == 1)
{
wendu1++; while(k1!=0);
if(wendu1>100) wendu1=100;
}
//温度-
if(k2 == 1)
{
wendu1--; while(k2!=0);
if(wendu1<1) wendu1=1;
}
//湿度+
if(k3 == 1)
{
shidu1++; while(k3!=0);
if(shidu1>100) shidu1=100;
}
//湿度-
if(k4 == 1)
{
shidu1--; while(k4!=0);
if(shidu1<1) shidu1=1;
}
}
int main(void)
{
IO_out();
GPIO_Configuration();//初始化
Init1602();
WrByte1602(0,1,' '); //字符显示
WrByte1602(0,2,'W');
WrByte1602(0,3,'D');
WrByte1602(0,4,'=');
WrByte1602(1,1,'S');
WrByte1602(1,2,'E');
WrByte1602(1,3,'T');
WrByte1602(1,4,'=');
WrByte1602(0,9,' ');
WrByte1602(0,10,'S');
WrByte1602(0,11,'D');
WrByte1602(0,12,'=');
WrByte1602(1,9,'S');
WrByte1602(1,10,'E');
WrByte1602(1,11,'T');
WrByte1602(1,12,'=');
delay_ms(500);
while(1)
{
anjiansaomiao();
//读取温湿度
DHT11_receive(&shidu,&wendu);
anjiansaomiao();
WrByte1602(0,5,AsciiCode[wendu%1000/100]);//显示温度
WrByte1602(0,6,AsciiCode[wendu%100/10]);
WrByte1602(0,7,AsciiCode[wendu%10]);
WrByte1602(0,13,AsciiCode[shidu%1000/100]); //显示湿度
WrByte1602(0,14,AsciiCode[shidu%100/10]);
WrByte1602(0,15,AsciiCode[shidu%10]);
WrByte1602(1,5,AsciiCode[wendu1%1000/100]); //显示温度阈值
WrByte1602(1,6,AsciiCode[wendu1%100/10]);
WrByte1602(1,7,AsciiCode[wendu1%10]);
WrByte1602(1,13,AsciiCode[shidu1%1000/100]); //显示湿度阈值
WrByte1602(1,14,AsciiCode[shidu1%100/10]);
WrByte1602(1,15,AsciiCode[shidu1%10]);
if(wendu>wendu1)//温度高于设置值 开始制冷
PCout(7)=0;
else PCout(7)=1;
if(wendu<wendu1)//温度低于设置值 开始加热
PCout(8)=0;
else PCout(8)=1;
if(shidu>shidu1)//湿度高于设置值 开始排气去湿
PCout(9)=0;
else PCout(9)=1;
if(shidu<shidu1)//湿度低于设置值 开始加湿
PCout(10)=0;
else PCout(10)=1;
}
}
五:仿真文件(采用Proteus打开)
六:资料清单展示(文件中包含的相关资料)