收藏 分享(赏)

51单片机Nokia5110的温湿度传感器DHT11温湿度显示的程序.doc

上传人:精品资料 文档编号:8996832 上传时间:2019-07-19 格式:DOC 页数:10 大小:5.66MB
下载 相关 举报
51单片机Nokia5110的温湿度传感器DHT11温湿度显示的程序.doc_第1页
第1页 / 共10页
51单片机Nokia5110的温湿度传感器DHT11温湿度显示的程序.doc_第2页
第2页 / 共10页
51单片机Nokia5110的温湿度传感器DHT11温湿度显示的程序.doc_第3页
第3页 / 共10页
51单片机Nokia5110的温湿度传感器DHT11温湿度显示的程序.doc_第4页
第4页 / 共10页
51单片机Nokia5110的温湿度传感器DHT11温湿度显示的程序.doc_第5页
第5页 / 共10页
点击查看更多>>
资源描述

1、单片机晶振为 11.0592MHz,LCD 液晶显示用 Nokia5110,当然用 LCD1602 也可以,只是要把显示部分的函数换了,温湿度传感器用 DHT11。LCD、DHT11、以及蜂鸣器用到的引脚在 PUBLIC.H 中有定义。只要把相关文件添加进工程即可WKC.C 如下#define uchar unsigned char#define uint unsigned intuchar timer0_count;/主函数入口void main()TMOD=0x01;TH0=0x4B;TL0=0xFF;ET0=1;EA=1;TR0=1;LCD_init(); /初始化 LCD 模块 whi

2、le(1);/定时器 0 中断服务函数void timer0() interrupt 1TH0=0x4B;TL0=0xFF;timer0_count+;if(timer0_count=20)Scan_DHT11();timer0_count=0;LCD5110.c 如下#include#include “PUBLIC.h“#define uchar unsigned char#define uint unsigned int/字符 6X12,阳码,列行式,逆向,十六进制unsigned char code mychar=0x00,0xE0,0x10,0x88,0x78,0x00,0x00,0x

3、03,0x03,0x00,0x00,0x00,/*“0“,0*/0x00,0x00,0xC0,0x30,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x00,/*“1“,1*/0x00,0x80,0x80,0xF0,0x80,0x00,0x00,0x03,0x03,0x00,0x00,0x00,/*“2“,2*/0x00,0x40,0x48,0xF8,0x00,0x00,0x00,0x00,0x00,0x03,0x00,0x00,/*“3“,3*/0x78,0x80,0xF0,0x40,0x40,0x20,0x00,0x00,0x03,0x00,0x00,0x00,/

4、*“4“,4*/0x00,0xF0,0x20,0x20,0x20,0x00,0x02,0x03,0x00,0x00,0x00,0x00,/*“5“,5*/0x00,0x80,0xC0,0xB0,0x88,0x00,0x00,0x03,0x02,0x02,0x01,0x00,/*“6“,6*/0x00,0x00,0x88,0x48,0x30,0x00,0x00,0x03,0x00,0x00,0x00,0x00,/*“7“,7*/0x00,0x88,0x58,0xE8,0x10,0x00,0x01,0x02,0x02,0x01,0x00,0x00,/*“8“,8*/0x00,0x30,0xA8,0

5、x78,0x10,0x00,0x00,0x02,0x01,0x00,0x00,0x00,/*“9“,9*/0x20,0x20,0xE0,0x30,0x18,0x08,0x00,0x00,0x03,0x02,0x01,0x00,/*“t“,10*/0x00,0xC0,0x38,0xE6,0x00,0x80,0x03,0x00,0x00,0x00,0x01,0x00,/*“h“,11*/0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,/*“:“,12*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x

6、00,0x00,0x00,0x00,0x00,/*“ “,13*/;/*Nokia5110 液晶写一个字节的函数入口参数 dt,command功能 写数据或写命令 1 为数据,0 为命令*/void LCD_write_byte(uchar dt, uchar command)uchar i; sce=0;dc=command;for(i=0;i#include “PUBLIC.h“#define uchar unsigned char#define uint unsigned intunsigned char DHT_Data5;/将温湿度的值写在 LCD 上void Dis_DHT_Dat

7、a(void) uchar i;for(i=0;i#include “PUBLIC.h“#define uchar unsigned char#define uint unsigned intvoid delayus(uchar a,uchar b,uchar c)/延时时间 a 的值 b 的值 c 的值 延时误差(us)/10us 1 1 1 -0.5 /20us 1 1 8 0 /30us 1 1 15 +0.5 /40us 2 1 9 0 /50us 1 1 28 0 /60us 1 1 35 +0.5 /70us 1 1 42 +1 /80us 1 1 48 0 /90us 1 1 5

8、5 +0.5 /100us 1 1 61 -0.5 /200us 1 1 128 0 /300us 3 1 63 +1.5 /400us 2 1 129 0 /500us 5 1 63 +0.5 /600us 6 1 63 0 /700us 7 1 63 -0.5 /800us 1 3 175 +0.5 /900us 9 1 63 -1.5 /1ms 1 3 219 -1.5/2ms 2 3 220 +3/3ms 3 3 220 +3/Xms X 3 220 +3 for(a=0;a1;a+)for(b=0;b1;b+)for(c=0;c1;c+);PUBLIC.H 如下#ifndef _PU

9、BLIC_H_#define _PUBLIC_H_/声明延时函数作用域为整个工程extern void delayus(unsigned char a,unsigned char b,unsigned char c);extern void Scan_DHT11(void);extern void LCD_init(void);extern void LCD_clear(void);extern void LCD_write_char(unsigned char row,unsigned char page,unsigned char c);extern void LCD_write_byte(unsigned char dt, unsigned char command);extern unsigned char DHT_Data5;sbit res = P07; /复位,0 复位sbit sce = P06; /片选sbit dc = P05; /1 写数据,0 写指令sbit sdin = P04; /数据sbit sclk = P27; /时钟sbit DHT = P03; /DHT11 的 datasbit BEEP = P02; /蜂鸣器#endif实际效果:

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报