標(biāo)題:
51單片機(jī)流水燈程序
[打印本頁]
作者:
夢(mèng)醒了11
時(shí)間:
2020-3-19 16:25
標(biāo)題:
51單片機(jī)流水燈程序
#include<reg52.h> //頭文件
#include<intrins.h> //調(diào)用_crol_循環(huán)右移函數(shù)
#define uint unsigned int //宏定義 uint
#define uchar unsigned char //宏定義 uchar
uchar temp; //定義變量
void delay(uint) ; //延時(shí)函數(shù)聲明
void main()
{ temp=0xfe; //點(diǎn)亮第一個(gè)發(fā)光二極管
P1=temp ; //值賦給P1口
while(1)
{
temp=_crol_(temp,1); //每次移一位 0000 0001 變成 00000010
delay(600) ; //延時(shí)600ms
P1=temp; //值賦給P1口
}
}
void delay(uint z) //延時(shí)函數(shù)
{
uint x,y;
for(x=110;x>0;x--)
for(y=z;y>0;y--);
}
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1