For a simple C51 programming: united digital tube water left shift how to write? The following program I feel can also, but I can't why how to change? Thank you
# include & lt; AT89X51. H>
int j;
Void delay ()
{
for(j=0; j<30000; J++);
}
Void main ()
{
Unsigned char led [8]={x4f x06 0, 0 x5b, 0, 0 x66, 0 x6d, 0 x7d, 0 x07, 0 x7f};
//1 2 3 4 5 6 7 8
Unsigned char wei [8]={XFD 0 xfe, 0, 0 XFB, 0 xf7, 0 xef, 0 XDF, 0 XBF, 0 x7f};
Unsigned int a;
Unsigned int b;
While (1)
{
For (a=0; A<8; +)
{
For (b=0; B<=a; B++)
{
P0=led [b];
P1=wei (a - b),
}
Delay ();
}
}
}
CodePudding user response:
Look from the code, embedded cycle too fast, so the eyes can't see it,
Released after use code that looks have administrative levels feeling,
CodePudding user response:
# include & lt; AT89X51. H> Unsigned char led [8]={x4f x06 0, 0 x5b, 0, 0 x66, 0 x6d, 0 x7d, 0 x07, 0 x7f}; //1 2 3 4 5 6 7 8 Unsigned char wei [8]={XFD 0 xfe, 0, 0 XFB, 0 xf7, 0 xef, 0 XDF, 0 XBF, 0 x7f}; int j; Void delay () { for(j=0; j<30000; J++); } Void main () { Unsigned int a; Unsigned int b; While (1) { For (a=0; A<8; +) { For (b=0; B<=a; B++) { P0=led [b]; P1=wei (a - b), } Delay (); } } } CodePudding user response:
reference 1/f, the wise know already should good karma response: look from code, embedded cycle too fast, so the eyes can't see it, Released after use code that looks have administrative levels feeling, Actually effect should be: can set number 8, the left one a mobile, digital tube display the complete number 8 after recycling, for example began to show 1, again according to 12, again shows 123, again shows that 1234... After this move to the left, to 12345678 the next show 1, again showing 12... This cycle... My inner loop add a delay or Circulate in a light like water, should soon can let each bit digital tube display different number How do you write for help? thank you CodePudding user response:
Unsigned char led [8]={254252248240224192128, 0};//water light after light one by one, on the whole from scratch Unsigned char wei [8]={x4f x06 0, 0 x5b, 0, 0 x66, 0 x6d, 0 x7d, 0 x07, 0 x7f};//replace segment value Void delay () { Unsigned int j; for(j=0; j<55555; J++); } Void main () { Unsigned char a; Unsigned char b; While (1) { For (a=0; A<8; +) { For (b=0; B<=a; B++) P0=wei [b]; P1=led [a]; Delay (); } } } With my LED digital tube and value, modify the test is normal, but your code digital tube only value, no value, you to write again, there is a problem again, Digital tube example reference https://blog.csdn.net/xianfajushi/article/details/85511846 CodePudding user response:
Unsigned char led [8]={254252248240224192128, 0};//water light after light one by one, on the whole from scratch Void delay () { Unsigned int j; for(j=0; j<55555; J++); } Void main () { Unsigned char a; Unsigned char b; While (1) { For (a=0; A<8; +) { For (b=0; B<=a; B++) P0=led [b]; P1=led [a]; Delay (); } } } Join you mean only digital tube to a value, then no period of value, is not show eight such period of symbols, so, can use value LED display completely, but can't see the 8 shows, program is still running normally, CodePudding user response:
According to your code is also wrong leds and the value of the WEI, can still see the application effect of modified Unsigned char wei [8]={x4f x06 0, 0 x5b, 0, 0 x66, 0 x6d, 0 x7d, 0 x07, 0 x7f}; //1 2 3 4 5 6 7 8 Unsigned char led [8]={XFD 0 xfe, 0, 0 XFB, 0 xf7, 0 xef, 0 XDF, 0 XBF, 0 x7f}; Void delay () { Unsigned int j; for(j=0; j<30000; J++); } Void main () { Unsigned char a; Unsigned char b; While (1) { For (a=0; A<8; +) { For (b=0; B<=a; B++) P1=wei [b]; P0=led [a]; Delay (); } } }