#include<reg52.h>
#define uchar unsigned char
unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//定义扫描列
unsigned char code digittab[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00, //0
0x00,0x00,0x00,0x00,0x21,0x7f,0x01,0x00, //1
0x00,0x00,0x27,0x45,0x45,0x45,0x39,0x00, //2
0x00,0x00,0x22,0x49,0x49,0x49,0x36,0x00, //3
0x00,0x00,0x0c,0x14,0x24,0x7f,0x04,0x00, //4
0x00,0x00,0x72,0x51,0x51,0x51,0x4e,0x00, //5
0x00,0x00,0x3e,0x49,0x49,0x49,0x26,0x00, //6
0x00,0x00,0x40,0x40,0x40,0x4f,0x70,0x00, //7
0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00, //8
0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00, //9
0x00,0x00,0x7F,0x48,0x48,0x30,0x00,0x00, //P
0x00,0x00,0x7F,0x48,0x4C,0x73,0x00,0x00, //R
0x00,0x00,0x7F,0x49,0x49,0x49,0x00,0x00, //E
0x00,0x00,0x3E,0x41,0x41,0x62,0x00,0x00, //C
0x00,0x00,0x7F,0x08,0x08,0x7F,0x00,0x00, //H
0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00, //I
0x00,0x7F,0x10,0x08,0x04,0x7F,0x00,0x00, //N
0x7C,0x48,0x48,0xFF,0x48,0x48,0x7C,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 //中
};//要显示的字符
void delay(int t)
{
int i;
for(i=1;i<=t;i++);
}//延时函数
void main(void)
{
int a,b,c;
while(1)
{
for(a=0;a<144;a++) //所有要显示的列数
{
for(b=0;b<50;b++)//控制移动速度
{
P2=0xfe; ///最右边的列先显示,程序定义向左移动
for(c=0;c<8;c++)//稍加修改可以变成向右移动
{ //例中P2接LED点阵阳极,P0接阴极
P0=digittab[a+c];//同时显示8列
delay(100);
P0=0x00; //禁止扫描列变换时,其它列亮!
P2=P2<<1|P2>>7;
}
}
}