为什么我调出来程序一直都是这样温度一点变化都没有求帮助谢谢
#include<reg51.h>
#include <intrins.h>
#include"lcd.h"
typedef unsigned char U8;
typedef signed char S8;
typedef unsigned int U16;
typedef signed int S16;
typedef unsigned long U32;
typedef signed long S32;
typedef float F32;
typedef double F64;
#define uchar unsigned char
#define uint unsigned int
sbit DHT = P2^0 ;
sbit JDQ = P2^7;
bit flagtemp;
bit flagsendtemp;
U8 U8FLAG;
U8 U8temp;
U8 U8T_data_H,U8T_data_L,U8RH_data_H,U8RH_data_L,U8checkdata;
U8 U8T_data_H_temp,U8T_data_L_temp,U8RH_data_H_temp,U8RH_data_L_temp,U8checkdata_temp;
U8 U8comdata;
U16 DHTData1,DHTData2;
U8 outdata[5];
U8 indata[5];
U8 count, count_r=0;
U8 RevData;
U8 str[5];
U8 data tab[6]={0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char PuZh[]="wendu shidu";
void Delay123(U16 j)
{ U8 i;
for(;j>0;j--)
{
for(i=0;i<27;i++);
}
}
void Delay_10us(void)
{
U8 i;
i--;
i--;
i--;
i--;
i--;
i--;
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void COM(void)
{
U8 i;
for(i=0;i<8;i++)
{
U8FLAG=2;
while((!DHT)&&U8FLAG++);
Delay_10us();
Delay_10us();
Delay_10us();
U8temp=0;
if(DHT)U8temp=1;
U8FLAG=2;
while((DHT)&&U8FLAG++);
if(U8FLAG==1)
break;
U8comdata<<=1;
U8comdata|=U8temp;
}//end i
}
void RH(void)
{
DHT=0;
Delay123(5);
DHT=1;
Delay_10us();
Delay_10us();
Delay_10us();
Delay_10us();
DHT=1;
if(!DHT) //T !
{
U8FLAG=2;
while((!DHT)&&U8FLAG++);
U8FLAG=2;
while((DHT)&&U8FLAG++);
COM();
U8RH_data_H_temp=U8comdata;
COM();
U8RH_data_L_temp=U8comdata;
COM();
U8T_data_H_temp=U8comdata;
COM();
U8T_data_L_temp=U8comdata;
COM();
U8checkdata_temp=U8comdata;
COM();
DHT=1;
U8temp=(U8T_data_H_temp+U8T_data_L_temp+U8RH_data_H_temp+U8RH_data_L_temp);
if(U8temp==U8checkdata_temp)
if(1)
{
U8RH_data_H = U8RH_data_H_temp;
U8RH_data_L = U8RH_data_L_temp;
DHTData1 = U8RH_data_H;
DHTData1 <<= 8;
DHTData1 |= U8RH_data_L;
tab[0]=DHTData1/100+0x30;
tab[1]=DHTData1%100/10+0x30;
tab[2]=DHTData1%10+0x30;
U8T_data_H = U8T_data_H_temp;
U8T_data_L = U8T_data_L_temp;
DHTData2 = U8T_data_H;
DHTData2<<=8;
DHTData2 |= U8T_data_L;
if(DHTData2&0x8000)
{
flagtemp=1;
DHTData2&=0x7FFF;
}
tab[3]=DHTData2/100+0x30;
tab[4]=DHTData2%100/10+0x30;
tab[5]=DHTData2%10+0x30;
//
U8checkdata=U8checkdata_temp;
}
}
}
void aa()
{
uchar dd[6];
dd[0]= tab[0] ;
dd[1]= tab[1];
dd[2]= tab[2];
//
dd[3]= tab[3] ;
dd[4]= tab[4];
dd[5]= tab[5];
//
//
LcdWriteCom(0x80+0x40+1);
if(flagtemp)LcdWriteCom('-');
else LcdWriteCom('+');
LcdWriteData(dd[0]);
LcdWriteData(dd[1]);
LcdWriteData('.');
LcdWriteData(dd[2]);
LcdWriteData('c');
//
LcdWriteCom(0x80+0x40+8);
LcdWriteData(dd[3]);
LcdWriteData(dd[4]);
LcdWriteData('.');
LcdWriteData(dd[5]);
LcdWriteData('%');
}
void main(void)
{
unsigned char i;
LcdInit();
LcdWriteCom(0x80+1);
for(i=0;i<12;i++)
{
LcdWriteData(PuZh);
}
while(1)
{
RH();
aa();
}
Delay123(20000);
}
|