/***************************************************************
* 程序名称:8*8LED动态显示简单汉字演示程序
* 实验对象:XY-850型单片机学习板
* 硬件说明:MCU采用AT89S51/52或STC89C51/52,
* 使用AT89C52单片机,
* 12MHZ晶振,P0口输出一行数据,P2口作行扫描,用共阳LED管
****************************************************************/
#include "reg51.h"
#define char unsigned char
#define int unsigned int
char key,keytmp;
char code distab[]=
{
/*******************************************/
0xEF,0x83,0xAB,0x83,0xAB,0x83,0xEE,0xE0,;电
0xFF,0xC7,0xEF,0x83,0xEF,0xEF,0xCF,0xEF, ;子
0xB1,0xB5,0x04,0xBF,0xB1,0xB5,0x9B,0xA4,;设
0xBB,0xBB,0x1B,0xA0,0xBB,0xBB,0x9B,0xBB,;计
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};
//
char code scan_con[8]=
{0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; // 列扫描
//********1毫秒延时************//
delay1ms(int t)
{
int i,j;
for(i=0;i<t;i++)
for(j=0;j<120;j++);
}
/***********逐字**********/
fun0()
{
int m,n,h;
for(h=0;h<32;h=h+8)
{for(n=0;n<100;n++)
{for(m=0;m<8;m++)
{P0=~distab[m+h];P2=scan_con[m];delay1ms(1);}
}
}
}
/***********向上滚动**********/
fun1()
{
int m,n,h;
for(h=0;h<32;h++) //控制显示字数(32/8=4个)
{for(n=0;n<10;n++) //控制帧移动速度
{for(m=0;m<8;m++) //显示1帧扫描(分8行,每行亮1毫秒)
{P0=~distab[m+h];P2=scan_con[m];delay1ms(1);}
}
}
}
//*********主程序**********//
main()
{
keytmp=1;
while(1)
{
switch(keytmp)
{
case 1:{fun0();break;}
case 2:{fun1();break;}
default:{break;}
}
}
}
//