一:功能描述
使流水灯按某一规律闪烁
二:程序
#include <REGX51.H>
#define uchar unsigned char
uchar code table[]={0x7f,0x3f,0x1f,0x0f,
0x07,0x03,0x01,0x00,
0x01,0x03,0x07,0x0f,
0x1f,0x3f,0x7f,0xff,
0x1f};
uchar i;
void delay(uchar ms);
void delay(uchar ms)
{
uchar i,j;
for(i=0;i<ms;i++)
for(j=0;j,125;j++)
;
}
void main(void)
{
while(1)
{
if(table[i]!=0x1f)
{
P1=table[i];
i++;
delay(1000);
}
else
{
i=0;
}
}
}