模拟花样广告灯显示实验
#include <REG51.H>
#define uchar unsigned char
#define uint unsigned int
uchar code LED1[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};
uchar code LED2[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar code LED3[]={0x7e,0xbd,0xdb,0xe7,0xe7,0xdb,0xbd,0x7e};
uchar code LED4[]={0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
uchar code LED5[]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
//-------------------------------------------------------------------
void delay(uint k)
{
uint i,j;
for (i=0;i<k;i++)
{
for (j=0;j<121;j++)
{;}
}
}
//-----------------------------------
void main(void)
{
uchar cnt;
while(1)
{
for(cnt=0;cnt<8;cnt++)
{
P1=LED1[cnt];
delay(200);
}
//------------------
for(cnt=0;cnt<8;cnt++)
{
P1=LED2[cnt];
delay(200);
}
//------------------
for(cnt=0;cnt<8;cnt++)
{
P1=LED3[cnt];
delay(200);
}
//------------------
for(cnt=0;cnt<8;cnt++)
{
P1=LED4[cnt];
delay(200);
}
//------------------
for(cnt=0;cnt<8;cnt++)
{
P1=LED5[cnt];
delay(200);
}
//------------------
}
} |