Sbit led0 P1=^ 0;
P1 sbit led1=^ 1;
Sbit led2=p ^ 2;
Sbit led3 P1=^ 3;
Sbit led4=P1 ^ 4;
Sbit led5=P1 ^ 5;
Sbit led6=P1 ^ 6;
Sbit led7=P1 ^ 7;
Void main ()
{unsigned char CNT=0, num=0, c=0; Led7=0; Led6=1; Led5=1; Led4=1; Led3=1; Led2=1; Led1=1; Led0=0; TMOD=0x01; TH0=0 xd8f0; TL0=0 x00; TR0=1; While (1) {if (TF0==1) {TF0=0; TH0=0 xd8f0; 0.01 s////10 ms TL0=0 x00; Cnt++; If (cnt>=5)//run 5 times, and is 50 ms {CNT=0; Led0=~ led0; Led1=~ led1; Led2=~ led2; Led3=~ led3; Led4=~ led4; Led5=~ led5; Led6=~ led6; Led7=~ led7; num++;//how many records go 50 ms}} if (num>=40)//less than 40 * 50 ms=2000 ms don't walk this program {TF0=0;//reset again TH0=0 xd8f0; TL0=0 x00; c++; Led0=0; Led1=0; Led2=0; Led3=0; Led4=0; Led5=0; Led6=0; Led7=0; If (c>=100), a 10 ms//overflow, overflow 100 times 1000 ms {led0=1; Led1=1; Led2=1; Led3=1; Led4=1; Led5=1; Led6=1; Led7=1; }}
}
}
CodePudding user response:
#includeSbit led0 P1=^ 0;
P1 sbit led1=^ 1;
Sbit led2=p ^ 2;
Sbit led3 P1=^ 3;
Sbit led4=P1 ^ 4;
Sbit led5=P1 ^ 5;
Sbit led6=P1 ^ 6;
Sbit led7=P1 ^ 7;
Void main ()
{
Unsigned char CNT=0, num=0, c=0;
Led7=0;
Led6=1;
Led5=1;
Led4=1;
Led3=1;
Led2=1;
Led1=1;
Led0=0;
TMOD=0x01;
TH0=0 xd8f0;
TL0=0 x00;
TR0=1;
While (1)
{
If (TF0==1)
{
TF0=0;
TH0=0 xd8f0; 0.01 s////10 ms
TL0=0 x00;
Cnt++;
If (cnt>=5)//run 5 times, and is 50 ms
{
CNT=0;
Led0=~ led0;
Led1=~ led1;
Led2=~ led2;
Led3=~ led3;
Led4=~ led4;
Led5=~ led5;
Led6=~ led6;
Led7=~ led7;
num++; How many 50 ms//records go
}
}
If (num>=40)//less than 40 * 50 ms=2000 ms don't walk this program
{
TF0=0;//reset again
TH0=0 xd8f0;
TL0=0 x00;
c++;
Led0=0;
Led1=0;
Led2=0;
Led3=0;
Led4=0;
Led5=0;
Led6=0;
Led7=0;
If (c>=100), a 10 ms//overflow, overflow 100 times 1000 ms
{
Led0=1;
Led1=1;
Led2=1;
Led3=1;
Led4=1;
Led5=1;
Led6=1;
Led7=1;
}
}
}
}
CodePudding user response:
I don't know why to squeeze aCodePudding user response: