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

單片機流水燈實驗程序

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

流水燈是很多初學(xué)者學(xué)習的一個程序,可以這么說是一個必學(xué)程序,舉個很簡單的它的應(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)//延時子程序
{
 uni x,y;
 for(x=z;x>0;x--)
  for(y=500;y>0;y--);
}

關(guān)閉窗口

相關(guān)文章