#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit D1=P1^0;
unsigned int a,t,D;
//uchar t;
void delay();
void main()
{
a=1;
TMOD=0X01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
REN=1;
SM0=0;
SM1=1;
TMOD=0X20;
TH1=0xfd;
TL1=0xfd;
TR1=1;
// EA=1;
// ES=1;
while(1)
{
if(a==1)
{
D1=0;
delay();
D1=1;
delay();
}
if(RI==1)
{
RI=0;
D=SBUF;
if(t>=D)
{
a=0;
D1=1;
}
}
}
}
void timer0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
t++;
// a=10;
}
void delay()
{
uint x,y;
for(x=1;x>0;x--)
for(y=80;y>0;y--);
}
//void ser() interrupt 4
//{
// RI=0;
// D=SBUF;
//} |