Home > other >  How to realize the 51 single-chip microcomputer 8 led flashing while running water
How to realize the 51 single-chip microcomputer 8 led flashing while running water

Time:10-28

Had not learned c, MCU course teacher let do this directly, now only makes light water, don't know how to change to water while flashing
Is running water in the code below, on the basis of how to change the flashing
# include & lt; reg51.h>
# define uchar unsigned char
Void delay05 ()
{uchar I, j, k;
For (I=5; I> 0; I -)
For (j=200; J> 0; J -)
For (k=250; K> 0; K -);
}
Void main ()
{uchar m, n;
While (1)
{n=0 x01;
For (m=0; M<=7. M++)
{
P1=~ n.
Delay05 ();
N=n<& lt; 1;
}
}
}

CodePudding user response:

His discovery tried to add lines of code, just don't know how to write flash a few times, while the control will flash a few times only copy a few times, bosses solutions
# include & lt; reg51.h>
# define uchar unsigned char
Void delay05 ()
{uchar I, j, k;
for(i=2; I> 0; I -)
For (j=200; J> 0; J -)
For (k=250; K> 0; K -);
}
Void main ()
{uchar m, n;
While (1)
{n=0 x01;
For (m=0; M<=7. M++)
{
P1=~ n.
Delay05 ();
P1=0 XFF;
Delay05 ();
P1=~ n.
Delay05 ();
P1=0 XFF;
Delay05 ();
P1=~ n.
Delay05 ();
P1=0 XFF;
Delay05 ();
P1=~ n.
Delay05 ();
P1=0 XFF;
Delay05 ();
N=n<& lt; 1;
}
}
}

CodePudding user response:

Write the same part can be extracted cycle
 
Char aa=0; While (aa<?).
{
P1=~ n.
Delay05 ();
P1=0 XFF;
Delay05 ();
}

CodePudding user response:

 
Char aa=0; While (aa++ & lt; ?).
{
P1=~ n.
Delay05 ();
P1=0 XFF;
Delay05 ();
}
  • Related