void InterruptTimer0(void) interrupt 1
{
static unsigned int sec;
static unsigned char a=0xfe,b=0;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
sec++;
if(sec%100==0)//閃爍周期0.2秒
{
b=~b;
P1=a|b;
}
if(sec>=1000)//移動周期1秒
{
sec=0;
a=a<<1|1;
if(a==0xff)
a=0xfe;
}
} |