Home > other >  Bosses asked to solve! Why long afterwards without running down!!!!!
Bosses asked to solve! Why long afterwards without running down!!!!!

Time:09-26

//twinkle can realize two seconds, all to light, from left to right in turn from right to left out
#include
#include
Void delay (unsigned int c);
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, w=0, b=0, a=0; int i=0; P1=1; 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++; How many times/record/overflow 10 ms if (cnt>=10)//run 10 times, and is 100 ms {CNT=0; P1=~ P1; num++; How many 100 ms//records go} if (num>=40)/less than 30 * 100=3000 ms/ms don't walk this program {TF0=0;//reset again TH0=0 xd8f0; TL0=0 x00; Cnt++; a++;//a=a + 1 if (a>=1) {P1=0 XFF; for(i=0; i<9. I++) {delay (20); P1 & gt;>=1; } led0=1; Delay (20); Led1=1; Delay (20); Led2=1; Delay (20); Led3=1; Delay (20); Led4=1; Delay (20); Led5=1; Delay (20); Led6=1; Delay (20); Led7=1; Delay (20); P1=0;//normally on delay (150); Led0=1; Led1=1; Led2=1; Led3=1; Led4=1; Led5=1; Led6=1; Led7=1;//destroy long delay (100);//upgrade can run normally TF0=0; TH0=0 xd8f0; 0.01 s////10 ms TL0=0 x00; B=0; W=0; If (TF0==1) {b++; How many times/record/overflow TF0=0; TH0=0 xd8f0; 0.01 s////10 ms TL0=0 x00; If (b>=30)//30 * 10=300 ms {P1=~ P1; W++; How many 300 ms//records go}/* if (w>=20)//20 * 300=6000 ms/} {} * break;//if}}}}
}
Void delay (unsigned int) c {unsigned char a, b; for (; C> 0; C -)
{the for (b=38; B> 0; B -) {for (a=130; A> 0; A -); }}
}

CodePudding user response:

Come up in a, this appearance is very ugly code

CodePudding user response:

//twinkle can realize two seconds, all to light, from left to right in turn from right to left out
#include
#include
Void delay (unsigned int c);
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, w=0, b=0, a=0;
int i=0;
P1=1;
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++; How many times/record/overflow 10 ms
If (cnt>=10)//run 10 times, and is 100 ms
{
CNT=0;
P1=~ P1;
num++; How many 100 ms//records go
}

If (num>=40)/less than 30 * 100=3000 ms/ms don't walk this program
{
TF0=0;//reset again
TH0=0 xd8f0;
TL0=0 x00;
Cnt++;
a++;//a=a + 1
If (a>
=1){
P1=0 XFF;
for(i=0; i<9. I++)
{
Delay (20);
P1 & gt;>=1;
}

Led0=1;
Delay (20);
Led1=1;
Delay (20);
Led2=1;
Delay (20);
Led3=1;
Delay (20);
Led4=1;
Delay (20);
Led5=1;
Delay (20);
Led6=1;
Delay (20);
Led7=1;
Delay (20);
P1=0;//normally on
Delay (150);
Led0=1;
Led1=1;
Led2=1;
Led3=1;
Led4=1;
Led5=1;
Led6=1;
Led7=1;//long out
delay(100);
//break;//upgrade can run normally
TF0=0;
TH0=0 xd8f0; 0.01 s////10 ms
TL0=0 x00;
B=0; W=0;
If (TF0==1)
{
B++;
TF0=0;
TH0=0 xd8f0; 0.01 s////10 ms
TL0=0 x00;
If (b>=30)//30 * 10=300 ms
{
P1=~ P1;
W++; How many 300 ms//records go
}

/* if (w>=20)//20 * 300=6000 ms
{

} */
} break;
}

}
}//if
}
}
Void delay (unsigned int c)
{
Unsigned char a, b;

for (; C> 0; C -)
{
For (b=38; B> 0; B -)
{
For (a=130; A> 0; A -);
}
}
}

CodePudding user response:

I'm sorry! No attention!

CodePudding user response:

Operation P1 mouth can, need not individually defined LED
  • Related