#include<reg52.h>
#define uint unsigned int
void delay(uint);
main()
{
uint fre=0x04;
uint fre1,fre2;
uint comp1=0xfe,comp2=0x80;
while(1)
{
/*--------------------------------------------------------------------
模块1:循环单向闪烁,只有一个灯亮灭
执行3次,转入下一种闪烁
--------------------------------------------------------------------------*/
P1=0xfe;
while(1!=fre--)
{
fre1=0x08;
while(1!=fre1--)
{
delay(3000000);
P1<<=1;
P1|=0x01;
if(P1==0x7f)
{
delay(3000000);
P1=0xfe;
}
}
}
/*-------------------------------------------------------------------
模块2:循环单向闪烁,只有两个灯亮或者灭
执行3次,转入下一种闪烁
--------------------------------------------------------------------*/
P1=0xfc;
while(3!=fre++)
{
fre2=0x04;
while(1!=fre2--)
{
delay(3000000);
P1<<=2;
P1|=0x03;
if(P1==0x3f)
{
delay(3000000);
P1=0xfc;
}
}
}
}
}
void delay(uint cnt)
{
while(cnt--);
}
帮忙给每句标一下注释,解释下什么意思,初学者
{
delay(3000000);
P1<<=1;
P1|=0x01;
if(P1==0x7f)
{
delay(3000000);
P1=0xfe;
}
P1后面的那根丨什么意思啊
或运算,那一句也就是相当于P1=P1|0x01,也就是把最低位置1
或运算,那一句也就是相当于P1=P1|0x01,也就是把最低位置1
本回答被提问者和网友采纳