Home > other >  51 microcontroller program to find errors, but led is not subject to control.
51 microcontroller program to find errors, but led is not subject to control.

Time:09-15

I am a rookie, you great god help me to find the problem, I found two days have not found the problem by themselves,

Topic: eight light-emitting tube spacing 200 ms top-down, bottom-up again and again, and then put out all shining with all 300 ms interval 5 times, repeat this process,

Code problem, I will only first leds light up, and then has been lit,

Is 89 c51 MCU, crystal frequency 11.0592 MHz

The HTML code is as follows, compile without error,

 
[/code] # include
#include
# define uchar unsigned char
# define uint unsigned int
Uchar aa;
Void delay (uint a);

Void main ()
{
Uchar I, j, k;
While (1)
{
for(i=0; i<3; I++)
{
Aa=0 xfe;
for(j=0; j<7. J++)
{
P1=aa;
Delay (200);
Aa=_crol_ (aa, 1);
}

Aa=0 x7f;
for(k=0; K<8; K++)
{
P1=aa;
Delay (200);
Aa=_cror_ (aa, 1);
}

}

P1=0 XFF;
for(j=0; j<10; J++)
{

P1=~ P1;
Delay (300);
}
}

}


Void delay (uint a)
{
Uint x, y;
For (x=a; a> 0; X -)
For (y=110; Y> 0; Y -);


}

CodePudding user response:

Can after changed delay,
To change the delay before the
Void delay (uint a)
{
Uint x, y;
For (x=a; a> 0; X -)
For (y=110; Y> 0; Y -);

After the change

Void delay (uint z)
{
Uint x, y;
For (x=0; XFor (y=0; Y<110; Y++);
}


Why do I feel that these two are the same, before the program is wrong?

CodePudding user response:

For (x=a; a> 0; X -)

CodePudding user response:

Upstairs right, for (x=a; a> 0; X -), instead of the for (x=a; x> 0; X -), the condition judgment was wrong

CodePudding user response:

Agree with the first floor, at the same time, remind, for this kind of problem can be used to add the print way to solution, with the printing should be very easy to find out what went wrong,
  • Related