- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
zhongjiechengxu 温度湿度程序(zhongjiechengxu温度湿度程序)
zhongjiechengxu 温度湿度程序(zhongjiechengxu温度湿度程序)
#包括“DHT11。”
#包括 reg52。”
/ /请根据自己的DHT11接的IO口来改动位定义
公司^ DHT11 = P0 0;
/ /防止在与硬件通信时发生死循环的计数范围
#定义20号
#定义尺寸5
静态无符号字符状态;
/ /存放五字节数据的数组
static unsigned char value_array [尺寸];
/ *可在其他的文件引用温湿度值,实际是温度的整数的10倍
如DHT11读回的温度是26,则temp_value = 260,湿度同理*/
国际temp_value,humi_value,temp_value1,humi_value1;
#定义unsigned char函数
# unsigned int定义单元
P3 ^了RS = 5;
公司lcden = P3 ^ 4;
公司^ K1 = P2 1;
公司^ K2 = P2 2;
公司K3 = P2 ^ 3;
公司^ K4 = P2 4;
普通T1 = P0 ^ 1;
公司T2 = P0 ^ 2;
公司T3 = P0 ^ 3;
普通T4 = P0 ^ 4;
函数代码文[ ] =“文下来的”;
函数代码石[ ] =“石下来的”;
函数代码AA [] =“”;
函数代码FF [] =“F”;
函数= 0,B = 40,C = 5,D = 40,E = 20,F = 0;
static unsigned char readvalue(void);
extern void delay_1ms(unsigned int MS)
{
无符号int x,y;
对于(x=ms;x=0;x)
{
为(y=124;y>0;y);
}
}
dht11_delay_10us静虚空(void)
{
未签名字符;
我--;
我--;
我--;
我--;
我--;
我--;
}
读一个字节的数据/ * * /
static unsigned char dht11_readvalue(void)
{
未签名的char计数,值= 0,i;
状态=好;/ /设定标志为正常状态
对于(i = 8;i 0;i…)
{
/ /高位在先
值 = 1;
计数= 0;
/ /每一位数据前会有一个50us的低电平时间等待50us低电平结束。
而(= = 0和DHT11数+ + 号码);
如果(计数=数)
{
状态=错误;/ /设定错误标志
return 0;//函数执行过程发生错误就退出函数
}
/ / 26-28us的高电平表示该位是0,为70us高电平表该位1
dht11_delay_10us();
dht11_delay_10us();
dht11_delay_10us();
/ /延时30us后检测数据线是否还是高电平
如果(DHT11!= 0)
{
进入这里表示该位是/ / 1
值+;
/ /等待剩余(约40us)的高电平结束
而(DHT11!= 0和计数+ + 数字)
{
DHT11 = 1;
}
如果(计数=数)
{
状态=错误;/ /设定错误标志
返回0;
}
}
}
返回值;
}
/ /读温度和湿度函数,读一次的数据,共五字节,
The read success function returns OK, and the error returns ERROR
Extern, unsigned, char, DHT11_ReadTempAndHumi (void)
{
Unsigned, char, I = 0, check_value = 0, count = 0;
EA = 0;
DHT11 = 0; / / low data line is greater than the 18ms to send the signal to start
Delay_1ms (20); / / must be greater than 18 milliseconds
DHT11 = 1; / / release the data line, for the detection of low level signal response
/ / delay 20-40us detection response signal for a period of time, the response signal from the machine low data line 80us
DHT11_Delay_10us ();
DHT11_Delay_10us ();
DHT11_Delay_10us ();
DHT11_Delay_10us ();
If (DHT11! = 0) / / the dete
您可能关注的文档
- 手机签名(Mobile signature).doc
- 手机用传感器(Sensor for mobile phone).doc
- 手机维修的工具和刷机软件(Mobile maintenance tools and brush software).doc
- 手的斗与簸箕(Bucket and dustpan hand).doc
- 手自一体驾驶方法(Hand in hand driving method).doc
- 手表的基础知识(Basic knowledge of watches).doc
- 手自一体变速器使用方法(Hand to hand transmission use method).doc
- 打印机偏色汇总(Printer color summary).doc
- 打开可信网站通道,globalsign宣布推出增强型 evssl 30 天试用型数字证书管理(Open the trusted web channel, globalsign announced the introduction of enhanced evssl 30 day trial digital certificate management).doc
- 打架检讨书(Fight book).doc
- zos环球高压打气筒 zos打气筒 zos高压打气筒 环球打气筒 zos环球超高压38mpa打气筒(Zos world high pressure inflator, zos inflator, zos high pressure inflator, global inflator, zos global ultra high pressure 38Mpa inflator).doc
- zte认证考题-管线专业(ZTE certified examination questions - Pipeline professionals).doc
- zulu外汇自动交易系统常见问题回答(Zulu Foreign Exchange Automated Trading System FAQ).doc
- 埃及工程承包市场状况(Status of construction contract market in Egypt).doc
- xx街道文教卫生科2006年上半年工作总结(Summary of the first half of 2006 of XX Street Education and health section).doc
文档评论(0)