//大写字母没有做,你自己搞吧
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar code Table_of_Digits[]=
{
0x00,0x3e,0x41,0x41,0x41,0x3e,0x00,0x00, //0
0x00,0x00,0x00,0x21,0x7f,0x01,0x00,0x00, //1
0x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00, //2
0x00,0x22,0x49,0x49,0x49,0x36,0x00,0x00, //3
0x00,0x0c,0x14,0x24,0x7f,0x04,0x00,0x00, //4
0x00,0x72,0x51,0x51,0x51,0x4e,0x00,0x00, //5
0x00,0x3e,0x49,0x49,0x49,0x26,0x00,0x00, //6
0x00,0x40,0x40,0x40,0x4f,0x70,0x00,0x00, //7
0x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00, //8
0x00,0x32,0x49,0x49,0x49,0x3e,0x00,0x00, //9
0xff,0x81,0x81,0x81,0x81,0x81,0x81,0xff
};
uchar code xdat[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
uchar code ydat[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
uchar i=0,j=0,t=0,Num_Index,key,xi,yi;
//主程序
void main()
{
P1=0x80;
Num_Index=0; //从0 开始显示
TMOD=0x01; //T0 方式0
TH0=(65536-2000)/256; //2ms 定时
TL0=(65536-2000)%256;
IE=0x82;
key=0;
xi=0;
yi=0;
EX0=1;
IT0=1;
TR0=1; //启动T0
while(1);
}
//T0 中断函数
void ext_int0() interrupt 0
{
key++;
key&=0x03;
}
void LED_Screen_Display() interrupt 1
{
TH0=(65536-2000)/256; //2ms 定时
TL0=(65536-2000)%256;
switch(key)
{
case 0:
P0=0xff; //输出位码和段码
P0=~Table_of_Digits[Num_Index*8+i];
P1=_crol_(P1,1);
if(++i==8) i=0; //每屏一个数字由8 个字节构成
if(++t==250) //每个数字刷新显示一段时间
{
t=0;
if(++Num_Index==10) Num_Index=0; //显示下一个数字
}
break;
case 1:
P0=~xdat[xi];
P1=0xff;
P1=ydat[yi];
if(++t==250) //每个数字刷新显示一段时间
{
t=0;
yi++;
if(yi>7){yi=0;xi++;}
if(xi>7)xi=0;
}
break;
case 2:
P0=0xff; //输出位码和段码
P0=~Table_of_Digits[80+j];
if(j==0)P1=0x80;
P1=_crol_(P1,1);
if(++j==8) j=0; //每屏一个数字由8 个字节构成
break;
default:
key=0;
i=0;
j=0;
t=0;
xi=0;
yi=0;
Num_Index=0;
P0=0xff;
P1=0x80;
break;
}
}