#include
sbit LED0=P1^0;
unsigned int t=0,k;
void dalay1ms (unsigned int i) //晶振选用11.0592
{
unsigned int j;
for(i;i>0;i--)
for(j=922;j>0;j--);
}
void main ()
{
EA=1;
ES=1;
TMOD=0x20; //定时器T1方式为2
TH1=0xfa; //波特率设定为9600
TL1=0xfa;
while(1)
{
if(t!=0)
{
k=2000/t;
dalay1ms (k) ;
LED0=!LED0;
}
if(t==0)
LED0=0;
}
}
void counter4(void) interrupt 4
{
while(RI==0);
RI = 0;
t= SBUF;
}