111-基于stm32单片机高低温恒温恒湿试验箱自动控制系统Proteus仿真+程序源码

一:功能介绍

1、采用stm32单片机+LCD1602+DHT11温湿度传感器+按键+电机,制作一个单片机高低温恒温恒湿试验箱自动控制系统;

2、通过按键设置温度和湿度的阈值,通过DHT11传感器采集温湿度;

3、当采集温度大于阈值,开启制冷模式,当温度小于设置温度,开启加热模式,当采集湿度大于阈值,开启排气模式,当湿度小于设置湿度,开启加湿模式;

4、LCD1602显示实时温湿度和按键设置的温湿度阈值;

二:仿真演示视频+程序简要讲解:(程序有中文注释,新手容易看懂)

111-基于stm32单片机高低温恒温恒湿试验箱自动控制系统Proteus仿真+程序源码+讲解视频

三:设计软件介绍

本设计使用C语言编程设计,程序代码采用keil5编写,程序有中文注释,新手容易看懂,仿真采用Proteus软件进行仿真演示视频使用的是Proteus8.9版本;资料包里有相关软件包,可自行下载安装。

四:程序打开方法

特别注意:下载资料包以后一定要先解压!(建议解压到桌面上,文件路径太深会导致程序打开异常),解压后再用keil5打开。

3e447bdf76b686abfb62f39881f4bd57.png

cc05d2ed24e55260e30b2ffcd5dbbfc6.png

程序部分展示,有中文注释,新手容易看懂
/*****************引脚配置********************/
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打开)

bf5ce385cd8a8f0e4b2788e43168297c.png

8e47cffde533c31a148cd322ac1ae97f.png

8f87359ad921c1c2db642b089096a4d2.png

六:资料清单展示(文件中包含的相关资料)

ae91f369f28cad30e356aa19cb98f317.png

百度云盘下载链接

  • 1
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值