资源描述:
《温湿度DHT11应用程序12864显示.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、温湿度DHT11应用程序12864显示#include#include#defineucharunsignedchar#defineuintunsignedintsbitdata1=P1^0;sbitsid=P3^6;//数据口sbitsclk=P3^7;//时钟sbitled=P2^0;//测试灯sbitled1=P2^1;sbitled2=P2^2;sbitled3=P2^3;ucharlcd_x,lcd_y,data_byte=0;ucharcount;uintU
2、8T_data_H,U8T_data_L,U8RH_data_H,U8RH_data_L,U8checkdata;uintU8T_data_H_temp,U8T_data_L_temp,num,U8RH_data_H_temp,U8RH_data_L_temp,U8checkdata_temp;//unsignedchartable[10]={"0123456789"};//ucharinttable1[8];unsignedcharstr1[]={""};unsignedcharstr2[]={""};un
3、signedcharcodelcd[]={"温湿度检测系统"};unsignedcharcodelcd1[]={"温度:"};unsignedcharcodelcd2[]={"湿度:"};unsignedcharcodelcd3[]={"℃"};unsignedcharcodelcd4[]={"%RH"};voidDelay2(uintz){uinti;for(i=z;i>0;i--){for(i=0;i>110;i--);}}voidDelay_10us(void){inti=5;i--;}ucharrec
4、e(){uchari,temp;for(i=0;i<8;i++){count=2;while((!data1)&&count++);//temp=0;Delay_10us();Delay_10us();Delay_10us();temp=0;if(data1==1)temp=1;count=2;while(data1&&count++);if(count==1)break;//temp=0;data_byte<<=1;data_byte
5、=temp;}return(data_byte);}//12864的串口
6、显示voiddelay(uintz){uintx,y;for(x=z;x>0;x--)for(y=110;y>0;y--);}voidsend(ucharbyte){uchari;for(i=0;i<8;i++){sid=byte&0x80;sclk=0;sclk=1;byte<<=1;}}voidwrite_date(uchardate){ucharstar_date,hdate,ldate;//if(star==0)//star_date=0xf8;//写指令//elsestar_date=0xfa;//
7、写数据hdate=date&0xf0;//取高4位ldate=(date<<4)&0xf0;//取低4位send(star_date);delay(1);send(hdate);delay(1);send(ldate);delay(1);}voidwrite_com(ucharcom){ucharstar_date,hdate,ldate;//if(star==0)star_date=0xf8;//写指令//else//star_date=0xfa;//写数据hdate=com&0xf0;//取高4位ldat
8、e=(com<<4)&0xf0;//取低4位send(star_date);delay(1);send(hdate);delay(1);send(ldate);delay(1);}voidlcd_dis_code(uintcmd_addr,ucharnum,uchardis[]){uinti;write_com(cmd_addr);for(i=0;i9、0x02);write_com(0x06);write_com(0x0c);write_com(0x01);write_com(0x80);delay(5);}voidlcd_pos(ucharx,uchary){ucharpos;if(x==1){x=0x80;}elseif(x==2){x=0x90;}elseif(x==3){x=0x88;}else{x=0x98;}write_com(y
10、p