#include
int cnt=0;
int x=0;
char state=1;
void tim0 () interrupt 1
{
TR0=0;
TH0=0x3C;
TL0=0xB0;
cnt++;
switch (state)
{
case 1:
P0=0x01;
if (cnt== 1200)
{
state=2;
cnt=0;
}
break;
case 2:
P0=0x02;
if (cnt== 2400)
{
state=3;
cnt=0;
}
break;
case 3:
P0=0x04;
if (cnt== 600)
{
state=4;
cnt=0;
}
break;
case 4:
P0=0x08;
if (cnt== 2400)
{
state=5;
cnt=0;
}
break;
case 5:
P0=0x04;
if (cnt== 600)
{
state=1;
cnt=0;
}
}
TR0=1;
}
void main ()
{
P0=0x00;
TMOD=TMOD&0xF0;
TMOD=TMOD|0x01;
TH0=0x3C;
TL0=0xB0;
EA=1;
ET0=1;
TR0=1;
while (1)
PCON=PCON|0x01;
}
Comments
Post a Comment
Thanks for the comment