ImageVerifierCode 换一换
格式:DOCX , 页数:23 ,大小:17.57KB ,
资源ID:9479038      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-9479038.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(STC15单片机DHT11在LCD1602上显示程序.docx)为本站会员(b****8)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

STC15单片机DHT11在LCD1602上显示程序.docx

1、STC15单片机DHT11在LCD1602上显示程序敬告:没有51单片机基础的人请慎重下载高质量实用性51单片机STC15W系列程序(4),STC8A系列可参考STC15单片机DHT11在LCD1602上显示程序注:在本节关于DHT11的程序有两种/*/版本一:/*/*/main函数程序:#include Library.hunsigned char strbuf4;/void ValToStr(unsigned char *str,unsigned char *source,unsigned char len);unsigned char tmrflag = 0;unsigned char

2、DHTbuf5;void Delay1000ms() /11.0592MHz unsigned char i, j, k; _nop_(); _nop_(); i = 43; j = 6; k = 203; do do while (-k); while (-j); while (-i);void main() unsigned char DHTstr8; P3M1 &= 0xBF; P3M0 &= 0xBF; P2M1 &= 0xE5; P2M0 &= 0xE5; P0M1 = 0x00; P0M0 = 0x00; LCD1602_init(); LCD1602_wBytes(2,0,.,1

3、); LCD1602_wBytes(8,0,humi,4); LCD1602_wBytes(2,1,.,1); LCD1602_wBytes(8,1,temp,4); while(1) DHT11_start(DHTbuf); / ValToStr(DHTstr,DHTbuf,sizeof(DHTbuf)-1); DHTstr0 = DHTbuf0/10 + 0; DHTstr1 = DHTbuf0%10 + 0; DHTstr2 = DHTbuf1/10 + 0; DHTstr3 = DHTbuf1%10 + 0; DHTstr4 = DHTbuf2/10 + 0; DHTstr5 = DH

4、Tbuf2%10 + 0; DHTstr6 = DHTbuf3/10 + 0; DHTstr7 = DHTbuf3%10 + 0; LCD1602_wBytes(0,0,DHTstr,2); LCD1602_wBytes(3,0,DHTstr+2,2); LCD1602_wBytes(0,1,DHTstr+4,2); LCD1602_wBytes(3,1,DHTstr+6,2); Delay1000ms(); Delay1000ms(); /void ValToStr(unsigned char *str,unsigned char *source,unsigned char len)/ un

5、signed char i;/ while(len0)/ / stri*2 = sourcei/10+0;/ str1+i*2 = sourcei%10+0; / i+;/ len-; / /*/DHT11程序:/*8bit humidity integer data + 8bit humidity decimal data8bit temperature integer data + 8bit temperature decimal data8bit check sum,high bit ahead*/#include Library.hunsigned char u8flag;unsign

6、ed char check_buf5;unsigned char tmp;void delay_1s() /11.0592MHz unsigned char i, j, k; _nop_(); _nop_(); i = 43; j = 6; k = 203; do do while (-k); while (-j); while (-i);void Delay10us() /11.0592MHz unsigned char i; _nop_(); i = 25; while (-i);void Delay20ms() /11.0592MHz unsigned char i, j, k; _no

7、p_(); _nop_(); i = 1; j = 216; k = 35; do do while (-k); while (-j); while (-i);unsigned char Rec_8bit() unsigned char i; unsigned char ret_8bit; unsigned char tmp; for(i=0;i8;i+) while(!DHT11port); Delay10us(); Delay10us(); Delay10us(); tmp = 0; if(DHT11port) tmp=1; u8flag = 2; while(DHT11port)&u8f

8、lag+); if(u8flag=1)break; ret_8bit0) LCD1602_wdat(*buf+); buf_len-; void OnCursor() LCD1602_wcmd(0x0F);void OffCursor() LCD1602_wcmd(0x0C);void LCD1602_init()/ Delay15ms();/ LCD1602_wcmd(0x38);/ Delay5ms(); LCD1602_wcmd(0x38);/ LCD1602_wcmd(0x08); LCD1602_wcmd(0x06); LCD1602_wcmd(0x0C); LCD1602_wcmd

9、(0x01);/*/Library.h#ifndef _Library_H#define _Library_H#include #include #define MAIN_Fosc 11059200Lsbit DHT11port = P36;void DHT11_start(unsigned char *rec_buf);sbit rs = P24;sbit rw = P23;sbit en = P21;void LCD1602_init();void LCD1602_wBytes(unsigned char x,unsigned char y,unsigned char *buf,unsig

10、ned char buf_len);#endif/*/版本二(结构体):/*/*/main程序:#include Library.h#include string.hvoid Delay1000ms() /11.0592MHz unsigned char i, j, k; _nop_(); _nop_(); i = 43; j = 6; k = 203; do do while (-k); while (-j); while (-i);void main() unsigned char DHTstr8; P3M1 &= 0xBF; P3M0 &= 0xBF; P2M1 &= 0xE5; P2M

11、0 &= 0xE5; P0M1 = 0x00; P0M0 = 0x00; LCD1602_init(); LCD1602_wBytes(2,0,.,1); LCD1602_wBytes(8,0,humi,4); LCD1602_wBytes(2,1,.,1); LCD1602_wBytes(8,1,temp,4); while(1) DHT11_start();/ memset(DHTstr, 0, 8); DHTstr0 = ht.humi_h +0 ; DHTstr1 = ht.humi_l+0 ; DHTstr2 = ht.humi_dh +0 ; DHTstr3 = ht.humi_d

12、l +0 ; DHTstr4 = ht.temp_h +0 ; DHTstr5 = ht.temp_l +0 ; DHTstr7 = ht.temp_dh +0 ; DHTstr6 = ht.temp_dl +0 ; LCD1602_wBytes(0,0,DHTstr,2); LCD1602_wBytes(3,0,DHTstr+2,2); LCD1602_wBytes(0,1,DHTstr+4,2); LCD1602_wBytes(3,1,DHTstr+6,2); Delay1000ms(); Delay1000ms(); /*/DHT11程序:/*8bit humidity integer

13、data + 8bit humidity decimal data8bit temperature integer data + 8bit temperature decimal data8bit check sum,high bit ahead*/#include Library.hunsigned char u8flag;unsigned char check_buf5;unsigned char tmp;unsigned char rec_buf4;htstruct ht;void delay_1s() /11.0592MHz unsigned char i, j, k; _nop_()

14、; _nop_(); i = 43; j = 6; k = 203; do do while (-k); while (-j); while (-i);void Delay10us() /11.0592MHz unsigned char i; _nop_(); i = 25; while (-i);void Delay20ms() /11.0592MHz unsigned char i, j, k; _nop_(); _nop_(); i = 1; j = 216; k = 35; do do while (-k); while (-j); while (-i);unsigned char R

15、ec_8bit() unsigned char i; unsigned char ret_8bit; unsigned char tmp; for(i=0;i8;i+) while(!DHT11port); Delay10us(); Delay10us(); Delay10us(); tmp = 0; if(DHT11port) tmp=1; u8flag = 2; while(DHT11port)&u8flag+); if(u8flag=1)break; ret_8bit=1; ret_8bit |= tmp; return ret_8bit;void DHT11_start()/ dela

16、y_1s(); DHT11port = 0; Delay20ms(); DHT11port = 1; Delay10us(); Delay10us(); Delay10us(); Delay10us(); /DHT11port = 1; if(!DHT11port) u8flag=2; while(!DHT11port)&u8flag+); u8flag=2; while(DHT11port)&u8flag+); check_buf0 = Rec_8bit(); check_buf1 = Rec_8bit(); check_buf2 = Rec_8bit(); check_buf3 = Rec

17、_8bit(); check_buf4 = Rec_8bit(); if(!DHT11port) while(!DHT11port); DHT11port = 1; tmp = check_buf0+check_buf1+check_buf2+check_buf3; if(tmp=check_buf4) rec_buf0 = check_buf0; rec_buf1 = check_buf1; rec_buf2 = check_buf2; rec_buf3 = check_buf3; ht.humi_h = rec_buf0/10 ; ht.humi_l = rec_buf0%10; ht.h

18、umi_dh = rec_buf1/10; ht.humi_dl = rec_buf1%10; ht.temp_h = rec_buf2/10; ht.temp_l = rec_buf2%10; ht.temp_dh = rec_buf3/10; ht.temp_dl = rec_buf3%10; else ht.humi_h = 0; ht.humi_l = 0; ht.humi_dh = 0; ht.humi_dl = 0; ht.temp_h = 0; ht.temp_l = 0; ht.temp_dh = 0; ht.temp_dl = 0; /*/LCD1602程序:#include

19、 Library.hvoid LCD1602_rsta() unsigned char tmp; P0 = 0xFF;/this is a must rs = 0; rw = 1; do en = 1; /Delay1us(); tmp = P0; /Delay1us(); en = 0; while(tmp&0x80);void LCD1602_wdat(unsigned char dat) LCD1602_rsta(); rs=1; rw=0; P0 = dat; en = 1; /Delay1us(); en = 0;void LCD1602_wcmd(unsigned char cmd) LCD1602_rsta(); rs=0; rw=0; P0 = cmd; en = 1; /Delay1us(); en = 0;void Setcursor(unsigned char x,unsigned char y) if(y=0) x = x + 0x00; else if(y=1) x = x + 0x40; LCD1602_wcmd(

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2