当前位置:   article > 正文

基于stm32单片机智能家居智能窗帘控制系统Proteus仿真和程序源码全套资料_stm32智能家居窗帘控制系统

stm32智能家居窗帘控制系统

 一:功能介绍

1、采用stm32单片机+LCD1602+DHT11温湿度传感器+DS1302传感器+光敏电阻+按键+电机,制作一个智能窗帘控制系统;

2、通过按键设置手动和自动模式,并且手动模式下可以通过按键控制窗帘打开和关闭;

3、自动模式下,可以通过光照强度来自动控制窗帘,当光照过低,自动关闭窗帘(夜晚);反之则打开窗帘(白天);

4、LCD1602显示ds1302时钟的时间和采集的温湿度、光照强度、以及当前的控制状态(自动或者手动);

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

92-基于stm32单片机智能家居智能窗帘控制系统Proteus仿真+程序源码+讲解视频

三:设计软件介绍

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

四:程序打开方法

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

52f1630451943ae3bbd3f0b95844abca.png

c11d461ccd01bbc6f1132b9843b20d4a.png

  1. 程序部分展示,有中文注释,新手容易看懂
  2. //IO口操作,只对单一的IO口!
  3. //确保n的值小于16!
  4. #define PAout(n) BIT_ADDR(GPIOA_ODR_Addr,n) //输出
  5. #define PAin(n) BIT_ADDR(GPIOA_IDR_Addr,n) //输入
  6. #define PBout(n) BIT_ADDR(GPIOB_ODR_Addr,n) //输出
  7. #define PBin(n) BIT_ADDR(GPIOB_IDR_Addr,n) //输入
  8. #define PCout(n) BIT_ADDR(GPIOC_ODR_Addr,n) //输出
  9. #define PCin(n) BIT_ADDR(GPIOC_IDR_Addr,n) //输入
  10. #define PDout(n) BIT_ADDR(GPIOD_ODR_Addr,n) //输出
  11. #define PDin(n) BIT_ADDR(GPIOD_IDR_Addr,n) //输入
  12. #define PEout(n) BIT_ADDR(GPIOE_ODR_Addr,n) //输出
  13. #define PEin(n) BIT_ADDR(GPIOE_IDR_Addr,n) //输入
  14. #define PFout(n) BIT_ADDR(GPIOF_ODR_Addr,n) //输出
  15. #define PFin(n) BIT_ADDR(GPIOF_IDR_Addr,n) //输入
  16. #define PGout(n) BIT_ADDR(GPIOG_ODR_Addr,n) //输出
  17. #define PGin(n) BIT_ADDR(GPIOG_IDR_Addr,n) //输入
  18. char buf=1,buf1=0;//buf是手动自动状态1:自动 0:手动 buf1是手动打开和关闭的状态 0:打开 1:关闭
  19. //毫秒级的延时
  20. void delay_ms(u16 time)
  21. {
  22. u16 i=0;
  23. while(time--)
  24. {
  25. i=800; //自己定义
  26. while(i--) ;
  27. }
  28. }
  29. /*****************DHT11********************/
  30. extern void DHT11_receive( int *h, int *t);
  31. /*****************引脚配置********************/
  32. void GPIO_Configuration(void)
  33. {
  34. GPIO_InitTypeDef GPIO_InitStructure;
  35. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB| RCC_APB2Periph_GPIOC| RCC_APB2Periph_GPIOC,ENABLE);
  36. RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
  37. RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,ENABLE);
  38. //LCD1602 管脚
  39. 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;
  40. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  41. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
  42. GPIO_Init(GPIOA, &GPIO_InitStructure);
  43. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 |GPIO_Pin_9|GPIO_Pin_10;
  44. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  45. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  46. GPIO_Init(GPIOB, &GPIO_InitStructure);
  47. //DHT11
  48. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;
  49. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  50. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
  51. GPIO_Init(GPIOB, &GPIO_InitStructure);
  52. //按键
  53. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0| GPIO_Pin_1| GPIO_Pin_2| GPIO_Pin_3| GPIO_Pin_4| GPIO_Pin_5;
  54. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
  55. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;;
  56. GPIO_Init(GPIOB, &GPIO_InitStructure);
  57. //配置 PA0 ADC采集模式
  58. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
  59. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  60. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
  61. GPIO_Init(GPIOA, &GPIO_InitStructure);
  62. //电机
  63. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14|GPIO_Pin_6;
  64. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  65. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  66. GPIO_Init(GPIOB, &GPIO_InitStructure);
  67. }
  68. /* ADC配置 */
  69. void ADC_Set(void)
  70. {
  71. ADC_InitTypeDef ADC_InitStructure;//ADC结构体变量//注意在一个语句快内变量的声明要放在可执行语句的前面,否则出错,因此要放在ADC1_GPIO_Config();前面
  72. ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;//ADC1和ADC2工作在独立模式
  73. ADC_InitStructure.ADC_ScanConvMode = DISABLE; //使能扫描
  74. ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;//ADC转换工作在连续模式
  75. ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;//由软件控制转换,不使用外部触发
  76. ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;//转换数据右对齐
  77. ADC_InitStructure.ADC_NbrOfChannel = 1;//转换通道为1
  78. ADC_Init(ADC1, &ADC_InitStructure); //初始化ADC
  79.   ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_28Cycles5);
  80. ADC_Cmd(ADC1, ENABLE);//使能ADC1
  81. ADC_SoftwareStartConvCmd(ADC1, ENABLE);
  82. }
  83. int wendu,shidu,guangqiang; //保存温度 湿度 光强
  84. int xiaoshi=70,fenzhong=20;// 湿度设定 光强设定
  85. u8 time_data[8];//保存时间的数组
  86. int nian=12,yue=34,ri=56;//保存年 月 日
  87. int shi=12,fen=34,miao=56;//保存
  88. //这里对按键进行扫描

:仿真文件(采用Proteus打开)

6e4ff3372ff1dc7c56ac8d5e4ac8a880.png

0b3721153953a79e8f67cff3f5546c74.png

9d2d74e1105f78001c354c685e22e232.png

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

bbfd7ae7d3531af187a57b3cc1712afe.png

百度云盘资料下载链接

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/616875
推荐阅读
相关标签
  

闽ICP备14008679号