“hello”翻滚程序
单片机数码管阳极接法,P0口段选,P2口位选
*********************************/
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar display[ ]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
// –H E L L O –
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
uchar shift,j=0;
void delayms(uint ms)
{
while(ms–)
for(t = 0; t < 120; t++);
}
}
void disp(void)
{
uchar i;
shift=0x7f;
for(i=8; i>0; i–)
P0=display[i+j];
P2=shift;
shift=(shift>>1)|0x80;
delayms(1);
}
void main()
{
uchar k;
P2=0xFF;
while(1)
for(j=0;j<17;j++)
{
for(k=0;k<125;k++)
disp();
}
}
}