温湿度传感器DHT11的驱动程序 - 温湿度传感器DHT11驱动程序
来源:网络整理 作者:2018年01月22日 16:52
[导读] 本文开始介绍了驱动程序的定义与驱动程序的作用,其次介绍了DHT11温湿度传感器特性、引脚说明与封装详情,最后介绍了温湿度传感器DHT11驱动程序。
三、温湿度传感器DHT11的驱动程序
#include “typedef.h”
#include 《msp430g2553.h》
#include “TemDHT11.h”
#ifndef _DHT11_TYPE
#define _DHT11_TYPE
//连接端口
#define DHT11_Dir P2DIR
#define DHT11_In P2IN
#define DHT11_Out P2OUT
#define DHT11_Bit BIT4
#endif
//8bit湿度+8bit湿度小数点
//8bit温度+8bit温度小数点
//数据位为0是高电平26~28us | 1高电平70us
u8 DHT11_Data[5] = {0}; //从DHT11中读到的数据
void read_DHT11(u8 *Data)
{
u8 re,m,n,Time_out;
DHT11_Dir &= (~DHT11_Bit); //引脚为输入
for(n = 0; n 《 5; n++)
{
for(m = 0; m 《 8; m++)