点阵LED显示器结构及汉字字模。设计16×16点阵LED显示器的驱动电路,编写程序实现在16×16点阵LED显示器上的汉字显示。16×16点阵LED显示器可由4块8×8点阵LED显示器构成。可采用单片机并行端口、移位寄存器、译码器或锁存器等4种驱动方式中的组合实现对16×16点阵LED显示器的驱动
电路方面主要包括以下3部分。
(a)设计单片机的最小系统(包括复位电路和外接的晶振电路),并确定相关元器件参数。
(b)采用动态驱动的方式,设计单片机并行端口、移位寄存器、译码器或锁存器等与16×16点阵LED显示器的驱动电路,主要包括控制点阵LED行和列的连线。
(c)采用移位寄存器、译码器或锁存器驱动点阵LED显示器时,设计单片机与移位寄存器、译码器或锁存器间的控制连线。
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
单片机源程序如下:
- #include<regx51.h>
- #include<intrins.h>
- #define uchar unsigned char
- #define clk P2_5
- #define sclk P2_6
- #define en P2_4
- #define dat P2_7
- void hang(uchar a)
- {
- uchar k;
- //p2=0;
- //en=1;
- for(k=0;k<8;k++)
- {
-
- dat=a&0x80;
- clk=1;
- clk=0;
- a<<=1;
- }
- }
- delay1ms(unsigned char m)
- {
- unsigned char n;
- while(m--)
- {
- for(n=0;n<122;n++);
- }
- }
- void main(void)
- {
- uchar i,j,q;
- uchar code a[32]=
- {0x04,0x00,0x04,0x00,0x0F,0xE0,0x10,0x20,0x20,0x40,0x7F,0xF8,0xA1,0x08,0x21,0x08,
- 0x3F,0xF8,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x01,0x02,0x01,0x02,0x00,0xFE,};
- uchar code b[32]=
- {0x00,0x08,0x20,0x3C,0x17,0xC0,0x14,0x00,0x84,0x1C,0x45,0xE0,0x45,0x20,0x15,0x22,
- 0x15,0x24,0x25,0x28,0xE5,0x10,0x25,0x10,0x25,0x08,0x29,0x44,0x29,0x82,0x11,0x00,};
- uchar code c[32]=
- {0x10,0x00,0x10,0x00,0x3F,0xFC,0x20,0x00,0x4F,0xF0,0x80,0x00,0x3F,0xF0,0x00,0x10,
- 0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x0A,0x00,0x0A,0x00,0x06,0x00,0x02,};
- uchar code d[32]=
- {0x00,0x40,0x00,0x40,0x00,0x40,0xFE,0x40,0x11,0xFC,0x10,0x44,0x10,0x44,0x10,0x44,
- 0x10,0x44,0x10,0x84,0x10,0x84,0x1E,0x84,0xF1,0x04,0x41,0x04,0x02,0x28,0x04,0x10,};
- while(1)
- {
- P2=0;
- en=1;
- for(j=0;j<62;j++)
- {
- for(i=0;i<32;i=i+2)
- {
- hang(a[i]);
- hang(a[i+1]);
- q=(31-i)/2;
- P2=P2&0xf0;
- P2=P2|q;
- sclk=1;
- sclk=0;
- delay1ms(1);
- }
- }
- for(j=0;j<62;j++)
- {
- for(i=0;i<32;i=i+2)
- {
- hang(b[i]);
- hang(b[i+1]);
- q=(31-i)/2;
- P2=P2&0xf0;
- P2=P2|q;
- sclk=1;
- sclk=0;
- delay1ms(1);
- }
- }
- for(j=0;j<62;j++)
- {
- for(i=0;i<32;i=i+2)
- {
- hang(c[i]);
- hang(c[i+1]);
- q=(31-i)/2;
- P2=P2&0xf0;
- P2=P2|q;
- sclk=1;
- sclk=0;
- delay1ms(1);
- }
- }
- for(j=0;j<62;j++)
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
16×16点阵LED显示器汉字显示——基于74HC595和74HC154驱动.rar
(52.25 KB, 下载次数: 210)
|