CodePudding user response:
#include#include
#include
# define uint unsigned int
# define uchar unsigned char
Uchar code table []={
X5b x3f 0, 0 x06, 0, 0 x4f, 0 x66,
X07 x6d 0, 0 x7d, 0, 0 x7f, 0 x6f
};
Sbit wela=P2 ^ 7;
Sbit dula=P2 ^ 6;
Sbit DHT=P3 ^ 7;
Uchar RH_data RL_data, TH_data TL_data, CK_data;
Uchar undata;
Void Delay35us ()//@ 11.0592 MHz
{
unsigned char i;
_nop_ ();
I=94;
While (I);
}
Void Delay8us ()//@ 11.0592 MHz
{
unsigned char i;
_nop_ ();
_nop_ ();
I=19;
While (I);
}
Void Delay800us ()//@ 11.0592 MHz
{
Unsigned char I, j;
_nop_ ();
_nop_ ();
_nop_ ();
I=9;
J=151;
Do
{
While (- j);
} while (--i);
}
Void Delay30us ()//@ 11.0592 MHz
{
unsigned char i;
_nop_ ();
_nop_ ();
I=80;
While (I);
}
Void Delay18ms ()//@ 11.0592 MHz
{
Unsigned char I, j, k;
I=1;
J=194;
K=160;
Do
{
Do
{
While (k);
} while (j);
} while (--i);
}
Uchar read_8bit ()//? Ae? O??? X?? U
{
Uint I;
Uchar temp=0;
Uchar dat.
for(i=0; I & lt; 8; I++)
{
while(! DHT);
Delay30us ();
Temp=0;
If==1 (DHT)
{
Temp=1;
}
While (DHT);
Dat<=1;
Dat=dat | temp;
}
Return dat.
}
Uchar read_data ()
{
Uint I;
DHT=1;
Delay8us ();
DHT=0;
Delay18ms ();
DHT=1;
Delay35us ();
if(! DHT)
{
while(! DHT);
While (DHT);
RH_data=(https://bbs.csdn.net/topics/read_8bit);
RL_data=(https://bbs.csdn.net/topics/read_8bit);
TH_data=(https://bbs.csdn.net/topics/read_8bit);
TL_data=(https://bbs.csdn.net/topics/read_8bit);
CK_data=(https://bbs.csdn.net/topics/read_8bit);
Undata=https://bbs.csdn.net/topics/RH_data + + TH_data RL_data + TL_data;
}
If (CK_data=https://bbs.csdn.net/topics/=undata)
{
I=1;
}
The else
{
i=0;
}
Return the I;
}
Void main ()
{
Uchar I;
While (1)
{
I=the read_data ();
If (I==1)
{
i=0;
Wela=1;
P0=0 xfe;
Wela=0;
Dula=1;
P0=table [10] RH_data/;
Dula=0;
Delay800us ();
Wela=1;
P0=0 XFD;
Wela=0;
Dula=1;
P0=table [10] RH_data %;
Dula=0;
Delay800us ();
Wela=1;
P0=0 xf7;
Wela=0;
Dula=1;
P0=table [10] TH_data/;
Dula=0;
Delay800us ();
Wela=1;
P0=0 xef;
Wela=0;
Dula=1;
P0=table [10] TH_data %;
Dula=0;
Delay800us ();
}
}
}