How can ability let the 51 single-chip led flashing while running water will have the most stupid method, due to space requirements, which bosses do want to a much less
CodePudding user response:
The space required? What is your original, to look at, just know how to streamline,
CodePudding user response:
reference 1/f, the wise know already should good karma response: length requirement? What is your original, to look at, just know how to streamline, { Delay (5000); The P2=0 XFF; Delay (5000); The P2=0 XBF; Delay (5000); The P2=0 XFF; Delay (5000); The P2=0 XDF; Delay (5000); The P2=0 XFF; Delay (5000); The P2=0 xef; Delay (5000); The P2=0 XFF; Delay (5000); The P2=0 xf7; Delay (5000); The P2=0 XFF; Delay (5000); The P2=0 XFB; Delay (5000); The P2=0 XFF; Delay (5000); The P2=0 XFD; Delay (5000); The P2=0 XFF; Delay (5000); The P2=0 xfe; } CodePudding user response:
reference 1/f, the wise know already should good karma response: length requirement? What is your original, to look at, just know how to streamline, This is the original circulation,,,,,,,, CodePudding user response:
Haven't learned, not even at the very least of all can't? ! Void LedXm () { The P2=0 XFF; } The main () { Unisgend char x=0; While (1) { Delay (5000); If (+ + x % 2) LedXm (); The else { If (x==2) P2=0 XBF; Else if (x==4) P2=0 XDF; Else if (x==6) P2=0 xef; Else if (x==8) P2=0 xf7; Else if (x==10) P2=0 XFB; Else if (x==12) P2=0 XFD; Else if (x==14) {P2=0 xfe; X=0; } } } CodePudding user response:
Above spelt wrong, correct and modify: The main () { Unsigend char x=0; While (1) { Delay (5000); If (+ + x % 2) P2=0 XFF;; The else { If (x==2) P2=0 XBF; Else if (x==4) P2=0 XDF; Else if (x==6) P2=0 xef; Else if (x==8) P2=0 xf7; Else if (x==10) P2=0 XFB; Else if (x==12) P2=0 XFD; Else if (x==14) {P2=0 xfe; X=0; } } } CodePudding user response:
The main () { Unsigned char x=0; While (1) { Delay (5000); If (+ + x % 2) P2=0 XFF;; The else { If (x==2) P2=0 XBF; Else if (x==4) P2=0 XDF; Else if (x==6) P2=0 xef; Else if (x==8) P2=0 xf7; Else if (x==10) P2=0 XFB; Else if (x==12) P2=0 XFD; Else if (x==14) {P2=0 xfe; X=0; } } } CodePudding user response:
refer to 6th floor wise men know already should good karma response: The main () { Unsigned char x=0; While (1) { Delay (5000); If (+ + x % 2) P2=0 XFF;; The else { If (x==2) P2=0 XBF; Else if (x==4) P2=0 XDF; Else if (x==6) P2=0 xef; Else if (x==8) P2=0 xf7; Else if (x==10) P2=0 XFB; Else if (x==12) P2=0 XFD; Else if (x==14) {P2=0 xfe; X=0; } } } Don't understand,,,,, I am just the self-study CodePudding user response:
Oh, that's good, for you are self-taught, you don't understand? First you read the program downloaded to the chip operation is correct, verify, So you give I modify program every sentence annotations, and see where you are I look not to know, Much like a semicolon, correct the: The main () { Unsigned char x=0; While (1) { Delay (5000); If (+ + x % 2) P2=0 XFF; The else { If (x==2) P2=0 XBF; Else if (x==4) P2=0 XDF; Else if (x==6) P2=0 xef; Else if (x==8) P2=0 xf7; Else if (x==10) P2=0 XFB; Else if (x==12) P2=0 XFD; Else if (x==14) {P2=0 xfe; X=0; } } } As you to directly modify the code, only be 7 leds, you carefully look at yourself, less copying code? CodePudding user response:
You should be a state of 7 f, less optimized for the first time, still can continue to optimize, such as the use of array: Void main () { Unsigned char aa []={0 XFF, 0 x7f, 0 XBF, 0 XDF, 0 xef, 0 xf7, 0 XFB, 0 XFD, 0 xfe}, x=0; Unsigned int y=0; While (1) { Y=20000; While (y -); If (+ + x % 2) P2=aa [0]; The else P2=aa [x/2]; If (x==16) x=0; } } CodePudding user response:
If you further study can also use the existing left moves to the right function to achieve the effect, of course, is beyond the questions from you, CodePudding user response:
Don't know if I understand right, a light, and then all the lights, then under a light... Cycle #include # define uchar unsigned char # define uint unsigned int uchar i; Uchar led []={0 x7f, 0 XBF, 0 XDF, 0 xef, 0 xf7, 0 XFB, 0 XFD, 0 xfe};//the led flashing order Void delay (uint t) {//delay While (t -); } Void main () { While (1) {//cycle flashing for(i=0; i<8; I++) { The P2=0 x00;//all of the lights will shine all Delay (60000); The P2=led [I];//in turn water flashing Delay (60000); } } } CodePudding user response:
My understanding is all black, and then a light, all black again, next lights again, all black again,,, All black a simple, direct, 0 XFF went, lighting parts with a 0, 7 1 byte, such as 0 x7f cyclic shift output, such as long as a simple cycle, Modify the loop byte value, can reach different lighting effect, such as use 0 x77 cyclic shift output: 0111, 0111, 1011, 1011, 1101, 1101, 1110, 1110,