/************************************************
硬件結(jié)構(gòu)框架:
1,八個(gè)LED發(fā)光二極管
2,MCU STC89C52
顯示效果:
1,讓led以流水燈的形式顯示
相關(guān)知識點(diǎn):
1,LED類顯示方式
************************************************/
#include"AT89x52.h"
#include"intrins.h"
#define uint unsigned int
#define uchar unsigned char
sbit WEI=P2^7; //74HC573的LE端 LED的位選端
sbit SJ=P1^4; //LED的使能端
void delay(uint z) //延時(shí)函數(shù)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
main() //主函數(shù)
{
uchar temp=0xfe;
WEI=1;
P0=0xff;
WEI=0; //上面三行代碼讓所有數(shù)碼管不顯示任何數(shù)值
SJ=0; //開LED發(fā)光管總使能
while(1) //循環(huán)執(zhí)行下面3行代碼
{
P0=temp;
temp=_crol_(temp,1); //移位
delay(200); //延時(shí)
}
}
謝謝老師,不過如果是要隔燈流水,那應(yīng)該怎么做,我原先那種燈少是比較容易實(shí)現(xiàn),但現(xiàn)在這種對我來說就很難了
弄出來了crol_移位值改過
| 歡迎光臨 (http://m.raoushi.com/bbs/) | Powered by Discuz! X3.1 |