專注電子技術(shù)學(xué)習(xí)與研究
當(dāng)前位置:單片機(jī)教程網(wǎng) >> MCU設(shè)計(jì)實(shí)例 >> 瀏覽文章

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

作者:佚名   來源:本站原創(chuàng)   點(diǎn)擊數(shù):  更新時(shí)間:2013年07月14日   【字體:

流水燈是很多初學(xué)者學(xué)習(xí)的一個(gè)程序,可以這么說是一個(gè)必學(xué)程序,舉個(gè)很簡單的它的應(yīng)用,很多生產(chǎn)線都需要用到左移,右移的操作,也許流水燈的程序就是最簡單的,也稱得上比較經(jīng)典的例子吧。

程序:#include<reg52.h>
#include<intrins.h>
#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--);
}

關(guān)閉窗口

相關(guān)文章