- 1
- 0
- 约6.44千字
- 约 19页
- 2017-10-10 发布于湖北
- 举报
基于单片机温湿度控制
基于单片机的温箱温度和湿度的控制 姓名:金义飞 学校:郑州大学 设计思路 温湿度采集传感器:DHT11 DHT11时序 温湿度显示:LCD1602 1602读写时序图 总电路图 程序如下: #include reg52.h #include intrins.h typedef unsigned char uchar; typedef unsigned int unint; unsigned char str1[]={}; unsigned char str2[]={}; unsigned char code dis1[] = {TRH RH: }; unsigned char code dis2[] = {TRH T: }; sbit TRH = P2^7;//温湿度传感器DHT11数据接入 sbit LCD_RS = P2^3; sbit LCD_RW = P2^4; sbit LCD_EN = P2^5; sbit jiare = P1^4; sbit jiangwen= P1^5; sbit zengshi= P1^6 sbit jiangshi= P1^7; uchar TH_data,TL_data,RH_data,RL_data,CK_data; uchar TH_temp,TL_temp,RH_temp,RL_temp,CK_temp; uchar com_data,untemp,temp; uchar respond; void delayNOP() { _nop_(); _nop_(); _nop_(); _nop_(); } void delay_us() //5us级延时程序 { uchar i; i--; i--; i--; i--; i--; i--; } void delay_ms(unsigned char ms) // 毫秒级延时子程序 { unsigned char i; while(ms--) { for(i = 0; i 150; i++) { _nop_(); _nop_(); _nop_(); _nop_(); } } } // 测试LCD忙碌状态lcd_busy()为1时,忙,等待。lcd_busy()为0时,闲,可写指令与数据。 bit lcd_busy() { bit result; LCD_RS = 0; LCD_RW = 1; LCD_EN = 1; delayNOP(); result = (bit)(P00x80); LCD_EN = 0; return(result); } // 写入指令数据到LCD void lcd_wcmd(unsigned char cmd) { while(lcd_busy()); LCD_RS = 0; LCD_RW = 0; LCD_EN = 0; _nop_(); _nop_(); P0 = cmd; delayNOP(); LCD_EN = 1; delayNOP(); LCD_EN = 0; } //写显示数据到LCD:RS=高电平,RW=低电平,E=高脉冲,D0-D7=数据。 void lcd_wdata(unsigned char dat) { while(lcd_busy()); LCD_RS = 1; LCD_RW = 0; LCD_EN = 0; P0
原创力文档

文档评论(0)