本文包含原理图、PCB、源代码、封装库、中英文PDF等资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
这是程序,是用c语言写的:
/*--------------------------------------
16×16点阵LED显示屏程序
MCU AT89C51 XAL 24MHz
Builde by Gavin Hu, 2003.8.15
--------------------------------------*/
#include <reg51.h>
#define BLKN 2 //列锁存器数
sbit G = 0x97; //P1.7为显示允许控制信号端口
sbit RCLK = 0x96; //P1.6为输出锁存器时钟信号端
sbit SCLR = 0x95; //P1.5为移位寄存器清○端
void delay(unsigned int); //延时函数
unsigned char data dispram[32]; //显示缓存
/*--------------------------------------
主函数 void main(void)
--------------------------------------*/
void main(void)
{
unsigned char code Bmp[][32]={//字模表
{
0xF9,0xBF,0xC7,0xAF,0xF7,0xB7,0xF7,0xB7,0xF7,0xBF,0x00,0x01,0xF7,0xBF,0xF7,0xB7,
0xF1,0xD7,0xC7,0xCF,0x37,0xDF,0xF7,0xAF,0xF6,0x6D,0xF7,0xF5,0xD7,0xF9,0xEF,0xFD
}/*我*/,
{
0xFF,0x07,0xC0,0x6F,0xED,0xEF,0xF6,0xDF,0xC0,0x01,0xDD,0xFD,0xBD,0xFF,0xC0,0x03,
0xFB,0xFF,0xF8,0x0F,0xF3,0xDF,0xF4,0xBF,0xEF,0x3F,0x9C,0xCF,0x73,0xF1,0xCF,0xFB
}/*爱*/,
{
0xF7,0xDF,0xF9,0xCF,0xFB,0xBF,0xC0,0x07,0xDE,0xF7,0xC0,0x07,0xDE,0xF7,0xDE,0xF7,
0xC0,0x07,0xDE,0xF7,0xFE,0xFF,0x00,0x01,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF
}/*单*/,
{
0xFF,0xBF,0xEF,0xBF,0xEF,0xBF,0xEF,0xBB,0xE0,0x01,0xEF,0xFF,0xEF,0xFF,0xEF,0xFF,
0xE0,0x0F,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xDF,0xEF,0xDF,0xEF,0xBF,0xEF,0x7F,0xEF
}/*片*/,
{
0xEF,0xFF,0xEF,0x07,0xEF,0x77,0x01,0x77,0xEF,0x77,0xEF,0x77,0xC7,0x77,0xCB,0x77,
0xAB,0x77,0xAF,0x77,0x6E,0xF7,0xEE,0xF5,0xED,0xF5,0xED,0xF5,0xEB,0xF9,0xEF,0xFF
}/*机*/,
{
0xF8,0x3F,0xE7,0xCF,0xDF,0xF7,0xBF,0xFB,0xB3,0x9B,0x73,0x9D,0x7F,0xFD,0x7F,0xFD,
0x6F,0xED,0x67,0xCD,0xB3,0x9B,0xB8,0x3B,0xDF,0xF7,0xE7,0xCF,0xF8,0x3F,0xFF,0xFF
}/*J*/
};
register unsigned char i,j,k,l;
SCON = 0x00; //串口工作模式0:移位寄存器方式
TMOD = 0x01; //定时器T0工作方式1:16位方式
TR0 = 1; //启动定时器T0
P1 = 0x3f; //P1端口初值:允许接收、锁存、显示
IE = 0x82; //允许定时器T0中断
while (1)
{
delay(2000); //延时2秒
for (i=0;i<32;i++) //显示效果:卷帘出┓
{
dispram = Bmp[5];
if (i%2) delay(100);
} //━━━━━━━━┛
delay(3000);
for (i=0; i<6; i++) //显示效果:上滚屏┓
{
for (j=0; j<16; j++)
{
for (k=0; k<15; k++)
{
dispram[k*BLKN] = dispram[(k+1)*BLKN];
dispram[k*BLKN+1] = dispram[(k+1)*BLKN+1];
}
dispram[30] = Bmp[j*BLKN];
dispram[31] = Bmp[j*BLKN+1];
delay(100);
}
} //━━━━━━━━┛
delay(3000);
for (i=0; i<6; i++) //显示效果:左跑马┓
{
for (j=0; j<2; j++)
for (k=1; k<9; k++)
{
for (l=0; l<16; l++)
{
dispram[l*BLKN] = dispram[l*BLKN]<<1 | dispram[l*BLKN+1]>>7;
dispram[l*BLKN+1] = dispram[l*BLKN+1]<<1 | Bmp[l*BLKN+j]>>(8-k);
}
delay(100);
}//end (k=0; k<16; k++)
}//end for (i=0; i<; i++)//━━━━━━━┛
delay(3000);
for (i=0;i<32;i++) //显示效果:卷帘入┓
{
dispram = 0x00;
if (i%2) delay(100);
} //━━━━━━━━┛
}//end while (1)
}
/*延时函数*/
void delay(unsigned int dt)
{
register unsigned char bt;
for (; dt; dt--)
for (bt=0; bt<255; bt++);
}
/*显示屏扫描(定时器T0中断)函数*/
void leddisplay(void) interrupt 1 using 1
{
register unsigned char i, j=BLKN;
TH0 = 0xF8; //设定显示屏刷新率每秒62.5帧
TL0 = 0x30;
i = P1; //读取当前显示的行号
i = ++i & 0x0f; //行号加1,屏蔽高4位
do {
j--;
SBUF = dispram[i*BLKN + j]; //送显示数据
while (!TI); TI = 0;
}while (j); //完成一行数据的发送
G = 1; //消隐(关闭显示)
P1 &= 0xf0; //行号端口清○
RCLK = 1; //显示数据打入输出锁存器
P1 |= i; //写入行号
RCLK = 0; //锁存显示数据
G = 0; //打开显示
}
|