新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)流水燈實(shí)驗(yàn)程序

單片機(jī)流水燈實(shí)驗(yàn)程序

作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 收藏
流水燈是很多初學(xué)者學(xué)習(xí)的一個(gè)程序,可以這么說(shuō)是一個(gè)必學(xué)程序,舉個(gè)很簡(jiǎn)單的它的應(yīng)用,很多生產(chǎn)線都需要用到左移,右移的操作,也許流水燈的程序就是最簡(jiǎn)單的,也稱(chēng)得上比較經(jīng)典的例子吧。

程序:#include
#include
#define uni unsigned int
#define unc unsigned char
void delay(int);
unc tems;
void main()
{
tems = 0xfe;
P1 = tems;//給P1口賦值
while(1)
{
tems = _cror_(tems,1);//移位操?
delay(300);
P1 = tems;
}
}
void delay(int z)//延時(shí)子程序
{
uni x,y;
for(x=z;x>0;x--)
for(y=500;y>0;y--);
}

本文引用地址:http://butianyuan.cn/article/201611/323762.htm


評(píng)論


技術(shù)專(zhuān)區(qū)

關(guān)閉