基于51单片机设计的16乘16LED点阵,运用74HC154和74LS04作为驱动16乘16LED点阵运行。
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
单片机源程序如下:
- #include<reg51.h>
- #define uchar unsigned char
- #define uint unsigned int
- #define out1 P1
- #define out0 P0
- #define out2 P2
- void delay(uint j)
- {
- uchar i=250;
- for(;j>0;j--)
- {
- while(--i);
- i=100;
- }
- }
- uchar code string[]=
- {
- 0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x03,0xE0,0x7B,0xEF,0x7B,0xEF,0x03,0xE0,0x7B,0xEF,
- 0x7B,0xEF,0x7B,0xEF,0x03,0xE0,0x7B,0xEF,0x7F,0xBF,0x7F,0xBF,0xFF,0x00,0xFF,0xFF,
- //
- 0xFF,0xFF,0x03,0xF0,0xFF,0xFB,0xFF,0xFD,0xFF,0xFE,0x7F,0xFF,0x7F,0xFF,0x7F,0xDF,
- 0x00,0x80,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x5F,0xFF,0xBF,0xFF,
- //
- 0xF7,0xFB,0xF7,0xFB,0xF7,0xFB,0x40,0x80,0xF7,0xFB,0xD7,0xFB,0x67,0xC0,0x73,0xEF,
- 0x74,0xEE,0xF7,0xF6,0xF7,0xF9,0xF7,0xF9,0xF7,0xF6,0x77,0x8F,0x95,0xDF,0xFB,0xFF,
- //
- 0x7F,0xFF,0x7F,0xFB,0x7F,0xF7,0x7F,0xFF,0x00,0x80,0x7F,0xFF,0x3F,0xFE,0x5F,0xFD,
- 0x5F,0xFB,0x6F,0xF7,0x77,0xE7,0x7B,0x8F,0x7C,0xDF,0x7F,0xFF,0x7F,0xFF,0xFF,0xFF
- };
-
- void main()
- {
- uchar i,j,n;
- while(1)
- {
- for(j=0;j<4;j++)
- {
- for(n=0;n<40;n++)
- {
- for(i=0;i<16;i++)
- {
- out1=i%16;
- out0=string[i*2+j*32];
- out2=string[i*2+1+j*32];
- delay(4);
- out0=0xff;
- out2=0xff;
- }
- }
- }
- }
- }
-
复制代码
所有资料51hei提供下载:
16乘16LED 点阵.zip
(69.63 KB, 下载次数: 53)
|