温度湿度热释传感器代码

上传人:子 文档编号:43399379 上传时间:2018-06-06 格式:DOC 页数:7 大小:30.50KB
返回 下载 相关 举报
温度湿度热释传感器代码_第1页
第1页 / 共7页
温度湿度热释传感器代码_第2页
第2页 / 共7页
温度湿度热释传感器代码_第3页
第3页 / 共7页
温度湿度热释传感器代码_第4页
第4页 / 共7页
温度湿度热释传感器代码_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《温度湿度热释传感器代码》由会员分享,可在线阅读,更多相关《温度湿度热释传感器代码(7页珍藏版)》请在金锄头文库上搜索。

1、温度湿度热释传感器代码温度湿度热释传感器代码#include #include “sys.h“#include “usart.h“#include “delay.h“#include “led.h“#include “key.h“ #include “dht11.h“ short temp,humi;int main(void)Stm32_Clock_Init(9);/系统时钟设置 delay_init(72); /延时初始化 uart_init(72,9600); /串口 1 初始化 LED_Init(); /LED 初始化 KEY_Init();while(1)temp=DHT11_Rea

2、dTempAndHumi(2);if(temp250)LED0=0;elseLED0=1;delay_ms(180);humi=DHT11_ReadTempAndHumi(0);if(humi550)LED1=0;elseLED1=1;delay_ms(180);if(KEYrs=1)LED1=0;elseLED1=1;#include #include “sys.h“#include “usart.h“#include “delay.h“#include “led.h“#include “key.h“#include “ds18b20.h“#include “dht11.h“ #includ

3、e “rtc.h“#include “timer.h“ #include “remort.h“ u16 key;u8 len,t0;u8 flag_t=1;u8 flag_h=1;u8 flag_rs=1;int main(void)Stm32_Clock_Init(9);/系统时钟设置 delay_init(72); /延时初始化 uart_init(72,9600); /串口 1 初始化 LED_Init(); KEY_Init(); dht11_int(); RTC_Init(); /LED 初始化RTC_ALR_Set(2013,8,13,21,06,00); /闹钟 LED1=0;J

4、TAG_Set(SWD_ENABLE);DS18B20_Init();PWM_Init(900,0); /不分频。PWM 频率=72000/9000=8Khz Remote_Init(); /初始化红外接收 while(!Remote_Rdy)LED0=0;LED1=0; LED0=1;LED1=1;key=Remote_Process();switch(key)case 104:while(1)key=1000;temp=DS18B20_Get_Temp();printf(“%hdn“,temp);if(temp300temp_mintor();flag_t=0; elseLED0=1; /

5、温度printf(“%hdn“,temp);humi=DHT11_ReadTempAndHumi(0);printf(“%hdn“,humi);if(humi500flag_h=0;elseLED1=1; /湿度if(KEYrs1=1| KEYrs2=1)flag_rs=0; elseLED1=1; /热释while(key!=0)delay_ms(1);if(USART_RX_STAyundong(400,400);delay_s(2);zhuanxi(0,0,0,0); printf(“temp:n“);USART_RX_STA=0;if(USART_RX_BUF0=b)zhuanxi(0

6、,1,0,1);yundong(400,400);delay_s(2);zhuanxi(0,0,0,0); printf(“humi:n“);USART_RX_STA=0;if(USART_RX_BUF0=c)zhuanxi(1,0,1,0);yundong(000,500);delay_s(2);zhuanxi(0,0,0,0);if(USART_RX_BUF0=d)zhuanxi(1,0,1,0);yundong(500,000);delay_s(2);zhuanxi(0,0,0,0);if(USART_RX_BUF0=e)temp=DS18B20_Get_Temp();printf(“%

7、hdn“,temp);humi=DHT11_ReadTempAndHumi(0);printf(“%hdn“,humi);if(Remote_Rdy)Sys_Soft_Reset();key-;case 152:LED0=1;LED1=1;KEY_Init(); /初始化与 ELD 连接的硬件接口 PWM_Init(900,0); /不分频。PWM 频率=72000/9000=8Khz JTAG_Set(SWD_ENABLE); zhuanxi(0,0,0,0);/yundong(200,200);while(1)while(!Remote_Rdy)LED0=0;key=Remote_Proc

8、ess();switch(key)case 98: zhuanxi(1,0,1,0);yundong(500,500);delay_s(2);zhuanxi(0,0,0,0);break; / “UP“ case 168:zhuanxi(0,1,0,1);yundong(500,500);delay_s(2);zhuanxi(0,0,0,0);break; / “DOWN“case 34: zhuanxi(1,0,1,0);yundong(000,500);delay_ms(500);zhuanxi(0,0,0,0);break; / “LEFT“case 194:zhuanxi(1,0,1,

9、0);yundong(600,000);delay_ms(500);zhuanxi(0,0,0,0);break; / “RIGHT“case 2: zhuanxi(1,0,0,1);yundong(500,500);delay_s(2);zhuanxi(0,0,0,0);break; / “PLAY“case 152:Sys_Soft_Reset();break;/ resetdelay_s(1);/Timerx_Init(499,7199);/10Khz 的计数频率,计数到 500 为 50ms,每 50MS 中断一次 /mapan(5); /调试速度相同,运行 5 秒/Timerx_dis();/ zhuanxi(0,1,0,1); / yundong(800,800);/ Timerx_Init(499,7199);/10Khz 的计数频率,计数到 500 为 50ms,每 50MS 中断一次 / mapan(5); /调试速度相同,运行 5 秒/ Timerx_dis(); / delay_s(10);/ zhuanxi(0,0,0,0); case 176:break;default:Sys_Soft_Reset(); /* pb7 和 8,蜂鸣器pc4 和 5,热释传感器pb4 6,dht:vcc gnd网在前,1 是 VCC*/

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号