设计思路:
利用8051单片机的两个并行I/O口,分别与8x8LED点阵的行与列引出端相连接,动态接口采用各列循环轮流显示的方法,当循环显示频率高时,利用人眼的暂留特性,使人看不出闪烁显示现象。在程序设计时对各列轮流扫描多遍以稳定显一个字符。我们想要显示什么数字只需要查表即可。
仿真元器清单:
AT89C51
BUTTON
CAP
CAP-ELEC
CRYSTAL
MATRIX-8x8-RED
RES
RESPACK-8
实现程序:
#include<reg51.h>
#define uchar unsigned char
#define unit unsigned int
int cntb;
uchar code tab[] = {0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar shou[1][8] =
{
{0x1F,0x11,0x1f,0x00,0x00,0x09,0x1F,0x01,},
};
uchar wei[1][8] =
{
{0x09,0x1F,0x01,0x00,0x00,0x1F,0x11,0x1f},
};
unit Num_Index;
uchar cnta;
uchar catb;
void main(void)
{
TMOD = 0x00;
TH0 = (8192-2000)/32;
TL0 = (8192-2000)%32;
TR0 = 1;
IE = 0x82;
while(1);
}
void t0(void)interrupt 1
{
TH0 = (8192-2000)/32;
TL0 = (8192-2000)%32;
P3 = tab[cnta];
P0 = shou[cntb][cnta];
P1 = tab[cnta];
P2 = wei[cntb][cnta];
cnta++;
if(cnta == 8)
{
cnta=0;
}
Num_Index++;
}
实现仿真图:
实现效果视频:
拓展:
可以利用字模工具,快速生成自己想要的字型
Comments NOTHING