#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit d_led=P2^5;
sbit dula=P2^6;
sbit wela=P2^7;
uchar code table[]={ //列显示数组
0xFF,0xFF,0xDB,0xA5,0xBD,0xDB,0xE7,0xFF,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xFF,0xC3,0xBD,0xBB,0xF7,0xEF,0xDF,0xC1
};
uchar code table1[]={ //行显示数组
0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80
};
delay(uint z)
{
while(z--);
}
void main()
{ uchar i,j,k,a;
wela=0;
while(1)
{
a=20;
while(a)
{
for(i=0;i<8;i++)
{
dula=1; //列显示
P0=table[j++];
dula=0;
d_led=1; //行显示
P0=table1[i];
d_led=0;
delay(200);
d_led=1; //清屏
P0=0x00;
d_led=0;
}
j++;
}
j++;
j=k;
if(k>32)
{
k=0;
}
i=0;
}
}
|