下面是参照一本书写的
#include
#define Dw 64 //显示区域长度
#define Dh 16 //显示区域高度
#define Lw 64 //LED屏宽度
#define Lh 16 //LED屏高度
#define Sw 16 //扫描宽度
#define EN_ON 1
#define EN_OFF 0
sfr Ctrl_port=0xa0;
sfr Data_port=0x80;
sbit E=P2^5; //显示允许控制端
sbit RCK=P2^6;//锁存信号
sbit SCK=P2^7;//移位信号
unsigned char code Display_Font[64][16]=
{
/*新*/
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x02,0x03,0x03,0x03, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x03, 0x01,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, 0x03,0x03,0x01,0x03,0x03,0x03,0x03,0x03,
//2
0x03,0x03,0x03,0x03,0x01,0x03,0x01,0x03, 0x03,0x03,0x03,0x01,0x01,0x01,0x03,0x03,
0x03,0x03,0x03,0x03,0x02,0x03,0x03,0x03, 0x03,0x03,0x03,0x03,0x02,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x03, 0x01,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, 0x01,0x01,0x01,0x01,0x03,0x03,0x03,0x03,
//3
0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x03,0x01,0x01,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x02,0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02,0x02,0x02,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x03, 0x01,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x01,0x01,0x01,0x01, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
//4
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03, 0x03,0x01,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x02,0x03,0x03,0x03,0x02, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x01,0x03,0x01,0x01,0x03,0x01,0x01, 0x01,0x03,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
//5
0x03,0x03,0x01,0x03,0x03,0x03,0x01,0x03, 0x03,0x01,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x02,0x03,0x03,0x03,0x03,0x02, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x01,0x03,0x01,0x03,0x01,0x03,0x03, 0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x01, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
//6
0x03,0x03,0x03,0x01,0x03,0x01,0x03,0x03, 0x03,0x01,0x03,0x03,0x03,0x01,0x03,0x03,
0x03,0x02,0x03,0x03,0x03,0x03,0x03,0x02, 0x03,0x03,0x03,0x02,0x03,0x03,0x03,0x03,
0x03,0x01,0x03,0x01,0x03,0x03,0x03,0x03, 0x01,0x03,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x01, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
//7
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x03,
0x03,0x03,0x03,0x02,0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02,0x02,0x03,0x03,0x03,
0x01,0x03,0x03,0x01,0x03,0x03,0x03,0x03, 0x01,0x03,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x01, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
//8
0x03,0x03,0x03,0x01,0x03,0x01,0x03,0x03, 0x03,0x01,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x03,0x02,0x03,0x03,0x03,0x02, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x03, 0x01,0x03,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x01, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
//9
0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x03, 0x03,0x01,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x03,0x02,0x03,0x03,0x03,0x02, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x03, 0x01,0x03,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x01,0x03,0x03,0x03,0x03,0x01, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
//10
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x03, 0x03,0x01,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x03,0x02,0x03,0x03,0x03,0x02, 0x03,0x03,0x03,0x03,0x03,0x02,0x03,0x03,
0x03,0x03,0x03,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x03,
0x03,0x01,0x03,0x03,0x03,0x03,0x03,0x01, 0x03,0x03,0x03,0x03,0x03,0x01,0x03,0x03,
//11
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x03, 0x03,0x01,0x03,0x03,0x01,0x03,0x03,0x03,
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02, 0x02,0x02,0x02,0x02,0x02,0x02,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x03, 0x01,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x01,0x01,0x01,0x01,0x01,0x01,0x01, 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x03,
//12
0x03,0x03,0x01,0x01,0x03,0x01,0x03,0x03, 0x03,0x01,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x02, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x01, 0x03,0x01,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x01,0x03,0x03,0x01, 0x03,0x03,0x01,0x03,0x03,0x03,0x03,0x03,
//13
0x03,0x01,0x03,0x01,0x03,0x03,0x01,0x01, 0x01,0x03,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x02, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x01, 0x03,0x03,0x01,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x01, 0x03,0x03,0x03,0x01,0x03,0x03,0x03,0x03,
//14
0x01,0x03,0x03,0x01,0x03,0x03,0x03,0x01, 0x01,0x03,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x02, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x03,0x01,0x03, 0x03,0x03,0x03,0x01,0x01,0x01,0x03,0x03,
0x03,0x03,0x01,0x03,0x03,0x03,0x03,0x01, 0x03,0x03,0x03,0x01,0x01,0x03,0x03,0x03,
//15
0x03,0x01,0x03,0x01,0x03,0x03,0x01,0x03, 0x03,0x03,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x02, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x03,0x01,0x03,0x03, 0x03,0x03,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x01,0x03,0x03,0x03,0x01,0x03,0x01, 0x03,0x03,0x03,0x03,0x01,0x03,0x03,0x03,
//16
0x03,0x03,0x01,0x03,0x03,0x03,0x03,0x03, 0x03,0x03,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x02, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
0x03,0x03,0x03,0x01,0x01,0x03,0x03,0x03, 0x03,0x03,0x03,0x03,0x01,0x03,0x03,0x03,
0x03,0x03,0x03,0x03,0x03,0x03,0x01,0x03, 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03
};
void display(unsigned int XL,unsigned int YL,unsigned int display_count)
{
unsigned char line;
unsigned char col;
unsigned char code *ram_point ;
unsigned int k,ram_begin_addr;
for(k=0;k
{
for(line=0;line
{
ram_begin_addr=Display_Font;
ram_point=ram_begin_addr+YL*Dw+XL+line*Dw ;
E=EN_ON;
for(col=Lw;col>0;col--)
{
Data_port=*ram_point;
SCK=0;
SCK=1;
ram_point++;
}
E=EN_OFF;
RCK=0;
RCK=1;
Ctrl_port=Ctrl_port&0xe0;
Ctrl_port=Ctrl_port|line;
}
}
}
void main(void)
{
unsigned int XL,YL,y,count=200;
while(1)
{
for(XL=0;XL
display(XL,0,count);//左移
}
}
这就是显示“新年快乐”那原程序,大家看能否改简单一点。
显示效果为
[url=http://img20.ph.126.net/TfC2c-T1sDHZ2BaJM8nCAw==/3170815612647392231.jpg][/url] |