#include<reg51.h>
sbit P1_0=P1^0;
sbit S1=P3^0;
bit flag;
void mDelay(unsigned int x)
{
unsigned int i,j;
for (i=x;i>0;i--)
for (j=0;j<114;j++);
}
void timer0() interrupt 1
{
P1_0=!P1_0;
TH0=(65536-461)/256;
TL0=(65536-461)%256;
}
void main(void)
{
TMOD = 0x01;
P1_0=0;
TH0=(65536-461)/256;
TL0=(65536-461)%256;
EA=1;
ET0=1;
TR0=0;
flag=0;
while(1) {
if(S1==0)
{
mDelay(10);
if(S1==0)
{
flag=~flag;
while(S1==0);
TR0=flag;
}
}
}
}