熟女俱乐部五十路二区av,又爽又黄禁片视频1000免费,国产卡一卡二卡三无线乱码新区,中文无码一区二区不卡αv,中文在线中文a

新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 基于51單片機(jī)的各種花樣的流水燈c51程序

基于51單片機(jī)的各種花樣的流水燈c51程序

作者: 時(shí)間:2012-09-11 來(lái)源:網(wǎng)絡(luò) 收藏

/*-----------------------------------------------
功能:燈對(duì)稱移動(dòng)閃爍(雙閃爍)

本文引用地址:http://www.bjwjmy.cn/article/170895.htm

------------------------------------------------*/

#includeREG52.H>
#define uint unsigned int
void delay(uint);
main()
{
uint comp1=0xfe;
uint comp2=0x80;
P1=0x7e;
delay(30000);
while(1)
{
P1=0xff;
comp1=1;
comp1|=0x01;
comp2>>=1;
P1=comp1;
P1^=comp2;
delay(30000);
if(P1==0xe7)
{
comp1=1;
comp1|=0x01;
comp2>>=1;
}

if(comp1==0x7f)
{
comp1=0xfe;
comp2=0x80;
}
}
}
void delay(uint cnt)
{
while(cnt--);
}


/*-----------------------------------------------------------------

只循環(huán)一次,而沒(méi)有一直循環(huán)下去,出錯(cuò)地方在:

通過(guò)添加一條測(cè)試語(yǔ)句:

if(comp1==0x7f)
{
comp1=0xfe; comp2=0x80;
P1=0x00; delay(30000);

}

發(fā)現(xiàn)if語(yǔ)句沒(méi)有被執(zhí)行,自然繼續(xù)左右移動(dòng):

1111 11111111 1111^0000 0000==11111 1111

所以看起來(lái)是執(zhí)行了一次while中的代碼。

具體為什么不行,還不清楚……

更正下列代碼后,能夠?qū)崿F(xiàn)功能。

if(P1==0x7e)
{
comp1=0xfe;
comp2=0x80;
}

或者:

if(comp2==0x01)
{
comp1=0xfe;
comp2=0x80;
}

--------------------------------------------------------------*/


上一頁(yè) 1 2 3 下一頁(yè)

評(píng)論


相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉