当前位置:   article > 正文

stm32毕业设计 单片机智能饮水控制系统_基于单片机的饮水机控制系统

基于单片机的饮水机控制系统


1 简介

Hi,大家好,学长今天向大家介绍一个学长做的单片机项目,不过这个项目是帮助企业研发的

基于单片机的智能饮水控制系统

大家可用于 毕业设计

选题指导,项目分享:

https://gitee.com/yaa-dc/warehouse-1/blob/master/iot/README.md

2 功能要求

  • 出水量达到设定值自动关水

  • 温度、湿度测量

  • 光照强度测量

  • 用水总量统计

  • NTP时间

  • 物联网,可在手机APP上远程查看室内温度、湿度、上电总次数等信息

  • 简洁易懂的UI界面

3 相关器件

在这里插入图片描述
在这里插入图片描述

4 实现效果

在这里插入图片描述
在这里插入图片描述

自己开发的APP

在这里插入图片描述

5 部分实现代码

仅部分代码

void TIM_Config(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;
	TIM_TimeBaseInitTypeDef	TIM_TimeBaseInitStruct;
	TIM_OCInitTypeDef  TIM_OCInitStructure;
	TIM_BDTRInitTypeDef TIM_BDTRInitStructure;
	
	NVIC_InitTypeDef NVIC_InitStructure;
	
	// ¿ªÆô¶¨Ê±Æ÷ʱÖÓ,¼´ÄÚ²¿Ê±ÖÓCK_INT=72M
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_TIM1, ENABLE);
	
   // Êä³ö±È½ÏͨµÀ1 GPIO ³õʼ»¯
	GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_8 | GPIO_Pin_9  ;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
		
	GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_13 | GPIO_Pin_14 ;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIOB, &GPIO_InitStructure);
	GPIO_SetBits(GPIOB, GPIO_Pin_13);
	GPIO_ResetBits(GPIOB, GPIO_Pin_14);
	
	TIM_DeInit(TIM1);        //½«ÍâÉèTIM1¼Ä´æÆ÷ÖØÉèΪȱʡֵ  
	TIM_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_DIV1 ;    //ÉèÖÃÁËʱÖÓ·Ö¸î(Tck_tim) 
	TIM_TimeBaseInitStruct.TIM_CounterMode = TIM_CounterMode_Up ;   //Ñ¡ÔñÁ˼ÆÊýÆ÷ģʽ(TIMÏòÉϼÆÊýģʽ)  
	TIM_TimeBaseInitStruct.TIM_Period = 6005 ;       //É趨¼ÆÊýÆ÷×Ô¶¯ÖØ×°Öµ,È¡Öµ·¶Î§0x0000~0xFFFF   
	TIM_TimeBaseInitStruct.TIM_Prescaler = 71 ;    //ÉèÖÃÓÃÀ´×÷ΪTIM3ʱÖÓƵÂʳýÊýµÄÔ¤·ÖƵֵΪ(79+1),È¡Öµ·¶Î§0x0000~0xFFFF 
	TIM_TimeBaseInitStruct.TIM_RepetitionCounter = 0;
	TIM_TimeBaseInit(TIM1, &TIM_TimeBaseInitStruct ) ;       
	
	/* ¶¨Ê±Æ÷Êä³öͨµÀ1ģʽÅäÖà */
 
  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;/* ģʽÅäÖãºPWMģʽ1 */
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;	 /* Êä³ö״̬ÉèÖãºÊ¹ÄÜÊä³ö */
  TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable; /* »¥²¹Í¨µÀÊä³ö״̬ÉèÖãºÊ¹ÄÜÊä³ö */
  TIM_OCInitStructure.TIM_Pulse = 3000;/* ÉèÖÃÌø±äÖµ£¬µ±¼ÆÊýÆ÷¼ÆÊýµ½Õâ¸öֵʱ£¬µçƽ·¢ÉúÌø±ä */
  
  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;/* µ±¶¨Ê±Æ÷¼ÆÊýֵСÓÚCCR1_ValʱΪ¸ßµçƽ */
  TIM_OCInitStructure.TIM_OCNPolarity= TIM_OCPolarity_High;
  TIM_OCInitStructure.TIM_OCIdleState = TIM_OCNIdleState_Reset;
  TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCNIdleState_Reset;
  
  TIM_OC1Init(TIM1, &TIM_OCInitStructure);
  
	TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;/* ģʽÅäÖãºPWMģʽ1 */
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;	 /* Êä³ö״̬ÉèÖãºÊ¹ÄÜÊä³ö */
  TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable; /* »¥²¹Í¨µÀÊä³ö״̬ÉèÖãºÊ¹ÄÜÊä³ö */
  TIM_OCInitStructure.TIM_Pulse = 3000;/* ÉèÖÃÌø±äÖµ£¬µ±¼ÆÊýÆ÷¼ÆÊýµ½Õâ¸öֵʱ£¬µçƽ·¢ÉúÌø±ä */
	
	TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;/* µ±¶¨Ê±Æ÷¼ÆÊýֵСÓÚCCR1_ValʱΪ¸ßµçƽ */
  TIM_OCInitStructure.TIM_OCNPolarity= TIM_OCPolarity_High;
  TIM_OCInitStructure.TIM_OCIdleState = TIM_OCNIdleState_Reset;
  TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCNIdleState_Reset;
	
	TIM_OC2Init(TIM1, &TIM_OCInitStructure);
 
 
  /* Automatic Output enable, Break, dead time and lock configuration*/
  TIM_BDTRInitStructure.TIM_OSSRState = TIM_OSSRState_Enable;
  TIM_BDTRInitStructure.TIM_OSSIState = TIM_OSSIState_Enable;
  TIM_BDTRInitStructure.TIM_LOCKLevel = TIM_LOCKLevel_OFF;
  TIM_BDTRInitStructure.TIM_DeadTime = 5;
  TIM_BDTRInitStructure.TIM_Break = TIM_Break_Disable;
  TIM_BDTRInitStructure.TIM_BreakPolarity = TIM_BreakPolarity_High;
  TIM_BDTRInitStructure.TIM_AutomaticOutput = TIM_AutomaticOutput_Enable;
  TIM_BDTRConfig(TIM1, &TIM_BDTRInitStructure);
  
  TIM_OC1PreloadConfig(TIM1,TIM_OCPreload_Enable);
  TIM_OC2PreloadConfig(TIM1,TIM_OCPreload_Enable);
 
	
  TIM_ARRPreloadConfig(TIM1, ENABLE);/* ʹÄܶ¨Ê±Æ÷ÖØÔؼĴæÆ÷ARR */
  TIM_Cmd(TIM1, ENABLE);/* ʹÄܶ¨Ê±Æ÷ */
  TIM_CtrlPWMOutputs(TIM1, ENABLE); /* TIMÖ÷Êä³öʹÄÜ */
  
  TIM_CCxCmd(TIM1,TIM_Channel_1,TIM_CCx_Enable);
  TIM_CCxNCmd(TIM1,TIM_Channel_1,TIM_CCxN_Enable);
  TIM_CCxCmd(TIM1,TIM_Channel_2,TIM_CCx_Enable);
  TIM_CCxNCmd(TIM1,TIM_Channel_2,TIM_CCxN_Enable);
 
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84

选题指导,项目分享:

https://gitee.com/yaa-dc/warehouse-1/blob/master/iot/README.md

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

闽ICP备14008679号