CodePudding user response:
The source code#include
Typedef unsigned int under-16;
Typedef unsigned char u8;
Void delay (under-16 I)
{
While (I -);
}
Sbit A=P2 ^ 2;
Sbit lB=P2 ^ 3;
Sbit C=P2 ^ 4;
U8 code led []={x5b x3f 0, 0 x06, 0, 0 x4f, 0 x66, 0 x6d, 0 x7d, 0 x07, 0 x7f, 0 x6f, 0 x77, 0 x7c, 0 x39, 0 x5e, 0 x79, 0 x71};
Void digdisplay () {
u8 i;
for(i=0; i<8; I++) {
The switch (I)
{
Case (0) :
A=0; LB=0; C=0; break;
Case (1) :
A=1; LB=0; C=0; break;
Case (2) :
A=0; LB=1; C=0; break;
Case (3) :
A=1; LB=1; C=0; break;
Case (4) :
A=0; LB=0; C=1; break;
Case (5) :
A=1; LB=0; C=1; break;
Case (6) :
A=0; LB=1; C=1; break;
Case (7) :
A=1; LB=1; C=1; break;
}
If (I=0) {P0=led [5];
delay(100);
P0=0 x00;
}
Else if (I=1) {P0=led [2];
delay(100);
P0=0 x00;
}
Else if (I=2) {P0=led [4];
delay(100);
P0=0 x00;
}
Else if (I=3) {P0=led [2];
delay(100);
P0=0 x00;
}
Else if (I=4) {P0=led [1];
delay(100);
P0=0 x00;
}
Else if (I=5) {P0=led [3];
delay(100);
P0=0 x00;
}
Else if (I=6) {P0=led [6];
delay(100);
P0=0 x00;
}
Else if (I=7) {P0=led [1];
delay(100);
P0=0 x00;
}
}
}
Void main ()
{
While (1)
{
Digdisplay ();
}
}
CodePudding user response:
Try to have deleted the elseCodePudding user response:
Can, your program in the switch and if statements are independent, but why don't you will in order to realize the function of both together?CodePudding user response:
You have a problem if it was not the=====is judgment,=is the assignmentCodePudding user response:
You should have reminded of the compilerCodePudding user response:
#include