#include"reg52.h"
#define uint unsigned int
#define uchar unsigned char
void delay(uint z)
{
uint i,j;
for(i=z;i>0;i--)
for(j=11;j>0;j--);
}
void main()
{
uint aa,bb;
aa=0xfe;//11111110
bb=0x7f;//01111111
while(1)
{
P1=aa;
delay(1000);
aa=aa<<1;
if(aa=0x00)
{
P1=0x00;
delay(1000);
P1=0xff;
delay(1000);
P1=0x00;
delay(1000);
P1=0xff;
delay(1000);
P1=0x00;
delay(1000);
P1=0xff;
delay(1000);
while(1)
{
P1=bb;
delay(1000);
bb=bb>>1;
if(bb==0x00)
{
P1=0x00;
delay(1000);
P1=0xff;
delay(1000);
P1=0x00;
delay(1000);
P1=0xff;
delay(1000);
P1=0x00;
delay(1000);
P1=0xff;
delay(1000);
while(1);
}
}
}
}
}
明显至少有一个问题
if(aa=0x00)
C语言的判断不是=,而是==
所以要改为
if(aa==0x00)
一周热门 更多>