新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > [C51代碼]廣告燈的循環(huán)移動(dòng)

[C51代碼]廣告燈的循環(huán)移動(dòng)

作者: 時(shí)間:2016-11-10 來源:網(wǎng)絡(luò) 收藏
#include

/************************************************/
sbit Key=P2^0;
static unsigned char p=0;

本文引用地址:http://butianyuan.cn/article/201611/317081.htm
void delay1ms(unsigned int count)
{
int x,y;
for(x=0;x for(y=0;y<120;y++);
}
/************************************************/
void ScanKey()
{
if(Key==0)
{
delay1ms(1);
if(Key==0)
{
p++;
if(p==8) p=0;
}
while(Key==0); //按鍵鎖定,每次按鍵只加1
}
}
/************************************************/
void main()
{
unsigned char i;
unsigned char a,b;
unsigned char temp=0x0f;
while(1)
{ ScanKey();
for(i=0;i<8;i++)
{
a=temp< b=temp>>(8-p);
P0=a|b;
}
}
}


評(píng)論


技術(shù)專區(qū)

關(guān)閉