LED点阵屏-16x16显示汉字,采用74hc595
16*16点阵屏的仿真原理图如下所示(proteus仿真工程文件可到附件中下载)
单片机源程序如下:
- #include <reg52.h>
- #include <intrins.h>
- #define uint unsigned int
- #define uchar unsigned char
- #define TEXT 16*2
- #define N 0
- sbit L_DI = P2^0; //HC595第14脚,串行数据输入端
- sbit L_LE = P2^1; //HC595第12脚,输出锁存脉冲输入端
- sbit L_CLK = P2^2; //HC595第11脚,串行时钟输入端
- sbit DI = P2^4; //HC595第14脚,串行数据输入端
- sbit LE = P2^5; //HC595第12脚,输出锁存脉冲输入端
- sbit CLK = P2^6; //HC595第11脚,串行时钟输入端
- uchar code Matrix[] =
- {
- 0x00, 0x00, 0xfe, 0x7f, 0x02, 0x28, 0x02, 0x24, 0x02, 0x23, 0xfe, 0x20, 0x02, 0x20, 0x02, 0x20,
- 0xfe, 0x21, 0x02, 0x22, 0x02, 0x22, 0x02, 0x22, 0x02, 0x22, 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, // 四
- 0x00, 0x00, 0x00, 0x80, 0x00, 0x60, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xfe, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, // 川
- 0x00, 0x40, 0xfc, 0x27, 0x00, 0x10, 0x00, 0x0e, 0xff, 0x01, 0x00, 0x00, 0xf2, 0x0f, 0x12, 0x00,
- 0x12, 0x00, 0x12, 0x00, 0xfe, 0xff, 0x12, 0x00, 0x12, 0x04, 0x12, 0x08, 0xf2, 0x07, 0x00, 0x00, // 师
- 0x44, 0x08, 0x94, 0x09, 0xa4, 0xf8, 0x64, 0x04, 0x04, 0x03, 0x0f, 0x00, 0x04, 0x00, 0xe4, 0x3f,
- 0x24, 0x40, 0x2c, 0x40, 0x2f, 0x42, 0x24, 0x46, 0xe4, 0x43, 0x04, 0x70, 0x04, 0x00, 0x00, 0x00, // 范
- 0x20, 0x00, 0x20, 0x80, 0x20, 0x40, 0x20, 0x20, 0x20, 0x10, 0x20, 0x0c, 0xa0, 0x03, 0x7f, 0x00,
- 0xa0, 0x01, 0x20, 0x06, 0x20, 0x08, 0x20, 0x30, 0x20, 0x60, 0x20, 0xc0, 0x20, 0x40, 0x00, 0x00, // 大
- 0x40, 0x00, 0x30, 0x02, 0x10, 0x02, 0x12, 0x02, 0x5c, 0x02, 0x54, 0x02, 0x50, 0x42, 0x51, 0x82,
- 0x5e, 0x7f, 0xd4, 0x02, 0x50, 0x02, 0x18, 0x02, 0x57, 0x02, 0x32, 0x02, 0x10, 0x02, 0x00, 0x00, // 学
- };
-
- void delay(uint z)
- {
- uint x, y;
- for (x=0; x<z; x++)
- for(y=0; y<120; y++);
- }
- //串行输出一个字节
- void HC595(uchar word)
- {
- uchar i;
- for (i=8;i>0;i--)
- {
- CLK=0;
- DI=0x80&word;
- word=_crol_(word,1);
- CLK=1;
- _nop_();
- }
- }
- void display(uchar L, uchar R)
- {
- HC595(L);
- HC595(R);
- LE=1;
- _nop_();
- LE=0;
- }
- void rightmove(bit b)
- {
- L_CLK=0;
- L_DI=b;
- L_CLK=1;
- _nop_();
- L_CLK=0;
- L_LE=1;
- _nop_();
- L_LE=0;
- }
- void init()
- {
- int i=0;
- L_LE = 0;
- LE = 0;
- for(i=0; i<TEXT; i++)
- rightmove(1);
- }
- void main()
- {
- uchar i=2;
- init();
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
11. LED点阵屏-16x16显示汉字.rar
(87.17 KB, 下载次数: 173)
|