自学内容网 自学内容网

基于51单片机的点阵式LED滚动显示屏设计(附源码)


一、点阵式LED滚动显示屏

1.题目要求

以51单片机为核心,设计并制作点阵式LED滚动显示屏

基本功能如下:
1.至少使用6个以上8*8的点阵来作为显示屏
2.通过左右滚动的方式来显示一首完整的古诗(如望庐山瀑布)

2.思路

首先,画个51单片机,粗略计算了一下好像引脚不是很够用,所以这里想用74HC138和74HC595级联的方式来驱动点阵。

在这里插入图片描述
74HC138B 译码器可接受三位二进制加权地址输入(A0,A1,A2)并在使能时,提供8 位低电平有效、互斥的输出(Y0 到 Y7)。至于具体输出高还是低,要根据下面的真值表来看(请注意实物中的E3其实是仿真图中的E1,要看引脚编号。)不懂的小伙伴可以看下这个74HC138译码器

在这里插入图片描述
这里显示屏采用了12个8*8的点阵来作为大显示屏

在这里插入图片描述

这也意味着我们需要用到12个74HC595进行级联不懂的小伙伴可以看下这个74HC595(8位串行输入、并行输出的缓存器)

如果一片595不够用,想要用多片且没有多余IO口呢,这时候就可以采用级联的方式来使用。这是因为一般情况是使用for循环一次性输入8个数据,当超过8个数据,多余的数据会从QH’输出。

级联的具体连接方式是将上一个74HC595的QH’输出端口连接到下一个74HC595的串行输入端口SER上,这样就可以通过移位寄存器时钟和锁存器将数据从一个74HC595移位到下一个74HC595,并最终输出到扩展的输出端口上。

在这里插入图片描述

3.仿真图

3.1 未仿真

在这里插入图片描述

3.2 仿真时

显示屏从左往右滚动显示古诗—望庐山瀑布。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

4.仿真程序

#include <reg51.h>

#define uchar unsigned char
#define uint unsigned int

sbit sh_cp=P3^0;
sbit ds=P3^1;
sbit st_cp=P3^2;

uchar num=50;

uchar code tab[]={
//望(0) 庐(1) 山(2) 瀑(3) 布(4) 唐(5) -(6) 李(7) 白(8) 日(9) 照(10) 香(11) 炉(12) 生(13) 紫(14) 烟(15)
// ,(16) 遥(17) 看(18) 瀑(19) 布(20) 向(21) 前(22) 川(23) ,(24) 飞(25) 流(26) 直(27) 下(28) 三(29) 千(30) 尺(31)
 //,(32) 疑(33) 是(34) 银(35) 河(36) 落(37) 九(38) 天(39) 。(40)

0x04,0x80,0x04,0x82,0xFC,0x92,0x45,0x92,0x46,0x92,0x24,0x92,0x24,0x92,0x04,0xFF,
0x80,0x92,0x7E,0x92,0x2A,0x92,0xAA,0x92,0x2A,0x93,0xFE,0x82,0x00,0x80,0x00,0x00,/*"望",0*/
/* (16 X 16 , 宋体 ) */

0x00,0x40,0x00,0x30,0xFC,0x0F,0x04,0x80,0x04,0x60,0xE4,0x1F,0x24,0x02,0x2D,0x02,
0x36,0x02,0x24,0x02,0x24,0x02,0x24,0x02,0xE4,0x07,0x04,0x00,0x04,0x00,0x00,0x00,/*"庐",1*/
/* (16 X 16 , 宋体 ) */

0x00,0x00,0x00,0x00,0xF0,0x3F,0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0xFF,0x3F,
0x00,0x20,0x00,0x20,0x00,0x20,0x00,0x20,0xF0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,/*"山",2*/
/* (16 X 16 , 宋体 ) */

0x10,0x04,0x60,0x04,0x02,0x7E,0x8C,0x01,0x00,0x01,0x40,0x09,0x5F,0x45,0xF5,0x2B,
0x55,0x91,0x55,0xFD,0x55,0x11,0xF5,0x2B,0x5F,0x45,0x40,0x09,0x00,0x01,0x00,0x00,/*"瀑",3*/
/* (16 X 16 , 宋体 ) */

0x08,0x02,0x08,0x01,0x88,0x00,0xC8,0x3F,0xA8,0x00,0x98,0x00,0x8F,0x00,0xE8,0xFF,
0x88,0x00,0x88,0x00,0x88,0x10,0x88,0x20,0x88,0x1F,0x08,0x00,0x08,0x00,0x00,0x00,/*"布",4*/
/* (16 X 16 , 宋体 ) */

0x00,0x40,0x00,0x30,0xFC,0x0F,0x44,0x00,0x54,0xFD,0x54,0x45,0x54,0x45,0x55,0x45,
0xFE,0x47,0x54,0x45,0x54,0x45,0x54,0x45,0xF4,0xFD,0x44,0x00,0x44,0x00,0x00,0x00,/*"唐",5*/
/* (16 X 16 , 宋体 ) */

0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x00,/*"-",6*/
/* (8 X 16 , 宋体 ) */

0x80,0x08,0x84,0x08,0x44,0x08,0x44,0x08,0x24,0x09,0x14,0x49,0x0C,0x89,0xFF,0x79,
0x0C,0x0D,0x14,0x0B,0x24,0x09,0x44,0x08,0x44,0x08,0x84,0x08,0x80,0x08,0x00,0x00,/*"李",7*/
/* (16 X 16 , 宋体 ) */

0x00,0x00,0x00,0x00,0xF8,0xFF,0x08,0x41,0x08,0x41,0x0C,0x41,0x0A,0x41,0x09,0x41,
0x08,0x41,0x08,0x41,0x08,0x41,0x08,0x41,0xF8,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,/*"白",8*/
/* (16 X 16 , 宋体 ) */

0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xFF,0x82,0x40,0x82,0x40,0x82,0x40,0x82,0x40,
0x82,0x40,0x82,0x40,0x82,0x40,0xFE,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"日",9*/
/* (16 X 16 , 宋体 ) */

0x00,0x80,0xFE,0x6F,0x42,0x08,0x42,0x08,0x42,0x28,0xFE,0xCF,0x00,0x00,0x42,0x00,
0xA2,0x2F,0x9E,0xC8,0x82,0x08,0xA2,0x08,0xC2,0x28,0xBE,0xCF,0x00,0x00,0x00,0x00,/*"照",10*/
/* (16 X 16 , 宋体 ) */

0x10,0x01,0x10,0x01,0x90,0x00,0x92,0xFF,0x52,0x49,0x32,0x49,0x12,0x49,0xFE,0x49,
0x12,0x49,0x31,0x49,0x51,0x49,0x91,0xFF,0x90,0x00,0x10,0x01,0x10,0x01,0x00,0x00,/*"香",11*/
/* (16 X 16 , 宋体 ) */

0x80,0x80,0x70,0x60,0x00,0x18,0xFF,0x07,0x10,0x88,0x08,0x50,0x00,0x30,0xF8,0x0F,
0x89,0x00,0x8E,0x00,0x88,0x00,0x88,0x00,0x88,0x00,0xF8,0x01,0x00,0x00,0x00,0x00,/*"炉",12*/
/* (16 X 16 , 宋体 ) */

0x80,0x40,0x40,0x40,0x30,0x42,0x1E,0x42,0x10,0x42,0x10,0x42,0x10,0x42,0xFF,0x7F,
0x10,0x42,0x10,0x42,0x10,0x42,0x10,0x42,0x10,0x42,0x10,0x40,0x00,0x40,0x00,0x00,/*"生",13*/
/* (16 X 16 , 宋体 ) */

0x20,0x00,0x20,0x80,0x3E,0x48,0x20,0x29,0x1F,0x09,0x94,0x4D,0x54,0x8D,0x00,0x7B,
0x1F,0x0B,0x24,0x09,0xA4,0x28,0x24,0x4C,0x22,0x98,0x38,0x00,0x00,0x00,0x00,0x00,/*"紫",14*/
/* (16 X 16 , 宋体 ) */

0x80,0x80,0x70,0x60,0x00,0x18,0xFF,0x07,0x10,0x08,0x08,0x10,0xFE,0xFF,0x42,0x50,
0x42,0x48,0x42,0x46,0xFA,0x41,0x42,0x42,0x42,0x4C,0x42,0x40,0xFE,0xFF,0x00,0x00,/*"烟",15*/
/* (16 X 16 , 宋体 ) */

0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*",",16*/
/* (16 X 16 , 宋体 ) */

0x40,0x00,0x40,0x80,0x42,0x40,0xCC,0x3F,0x00,0x40,0x00,0x80,0x4A,0x81,0x32,0xBD,
0x22,0xA1,0x2A,0xA1,0xF1,0xBF,0x21,0xA1,0x31,0xA1,0x2D,0xBD,0x00,0x81,0x00,0x00,/*"遥",17*/
/* (16 X 16 , 宋体 ) */

0x20,0x08,0x22,0x04,0x2A,0x02,0x2A,0x01,0xAA,0xFF,0x6A,0x55,0x3A,0x55,0x2E,0x55,
0x29,0x55,0x29,0x55,0x29,0x55,0x29,0xFF,0x29,0x00,0x20,0x00,0x20,0x00,0x00,0x00,/*"看",18*/
/* (16 X 16 , 宋体 ) */

0x10,0x04,0x60,0x04,0x02,0x7E,0x8C,0x01,0x00,0x01,0x40,0x09,0x5F,0x45,0xF5,0x2B,
0x55,0x91,0x55,0xFD,0x55,0x11,0xF5,0x2B,0x5F,0x45,0x40,0x09,0x00,0x01,0x00,0x00,/*"瀑",19*/
/* (16 X 16 , 宋体 ) */

0x08,0x02,0x08,0x01,0x88,0x00,0xC8,0x3F,0xA8,0x00,0x98,0x00,0x8F,0x00,0xE8,0xFF,
0x88,0x00,0x88,0x00,0x88,0x10,0x88,0x20,0x88,0x1F,0x08,0x00,0x08,0x00,0x00,0x00,/*"布",20*/
/* (16 X 16 , 宋体 ) */

0x00,0x00,0xF8,0xFF,0x08,0x00,0x08,0x00,0x0C,0x00,0xCA,0x1F,0x49,0x08,0x48,0x08,
0x48,0x08,0xC8,0x1F,0x08,0x00,0x08,0x40,0x08,0x80,0xF8,0x7F,0x00,0x00,0x00,0x00,/*"向",21*/
/* (16 X 16 , 宋体 ) */

0x08,0x00,0x08,0x00,0xE8,0xFF,0x29,0x09,0x2E,0x49,0x28,0x89,0xE8,0x7F,0x08,0x00,
0x08,0x00,0xC8,0x0F,0x0C,0x40,0x0B,0x80,0xE8,0x7F,0x08,0x00,0x08,0x00,0x00,0x00,/*"前",22*/
/* (16 X 16 , 宋体 ) */

0x00,0x80,0x00,0x40,0x00,0x30,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFE,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00,0x00,/*"川",23*/
/* (16 X 16 , 宋体 ) */

0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*",",24*/
/* (16 X 16 , 宋体 ) */

0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,
0x02,0x00,0xFE,0x03,0x40,0x0C,0xA0,0x10,0x10,0x21,0x08,0x42,0x00,0xF0,0x00,0x00,/*"飞",25*/
/* (16 X 16 , 宋体 ) */

0x10,0x04,0x60,0x04,0x02,0x7E,0x8C,0x01,0x00,0x80,0x44,0x40,0x64,0x3E,0x54,0x00,
0x4D,0x00,0x46,0xFE,0x44,0x00,0x54,0x00,0x64,0x7E,0xC4,0x80,0x04,0xE0,0x00,0x00,/*"流",26*/
/* (16 X 16 , 宋体 ) */

0x00,0x40,0x04,0x40,0x04,0x40,0xF4,0x7F,0x94,0x4A,0x94,0x4A,0x94,0x4A,0x9F,0x4A,
0x94,0x4A,0x94,0x4A,0x94,0x4A,0xF4,0x7F,0x04,0x40,0x04,0x40,0x00,0x40,0x00,0x00,/*"直",27*/
/* (16 X 16 , 宋体 ) */

0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0xFE,0xFF,0x02,0x00,
0x02,0x00,0x42,0x00,0x82,0x00,0x02,0x01,0x02,0x06,0x02,0x00,0x02,0x00,0x00,0x00,/*"下",28*/
/* (16 X 16 , 宋体 ) */

0x00,0x20,0x04,0x20,0x84,0x20,0x84,0x20,0x84,0x20,0x84,0x20,0x84,0x20,0x84,0x20,
0x84,0x20,0x84,0x20,0x84,0x20,0x84,0x20,0x84,0x20,0x04,0x20,0x00,0x20,0x00,0x00,/*"三",29*/
/* (16 X 16 , 宋体 ) */

0x80,0x00,0x80,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0x84,0x00,0xFC,0xFF,
0x82,0x00,0x82,0x00,0x82,0x00,0x83,0x00,0x82,0x00,0x80,0x00,0x80,0x00,0x00,0x00,/*"千",30*/
/* (16 X 16 , 宋体 ) */

0x00,0x80,0x00,0x40,0x00,0x30,0xFE,0x0F,0x42,0x00,0x42,0x00,0x42,0x00,0x42,0x00,
0xC2,0x03,0x42,0x0C,0x42,0x10,0x42,0x20,0x7E,0x40,0x00,0x80,0x00,0x80,0x00,0x00,/*"尺",31*/
/* (16 X 16 , 宋体 ) */

0x00,0x00,0x00,0x00,0x00,0x58,0x00,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*",",32*/
/* (16 X 16 , 宋体 ) */

0x00,0x85,0xDF,0x44,0xA4,0x34,0xA4,0x0F,0xA2,0x14,0xBA,0x64,0x00,0x84,0x22,0x60,
0x22,0x1F,0x2A,0x10,0xF2,0x3F,0x2A,0x42,0xA6,0x42,0x62,0x40,0x20,0x40,0x00,0x00,/*"疑",33*/
/* (16 X 16 , 宋体 ) */

0x00,0x81,0x00,0x41,0x00,0x21,0x7F,0x1D,0x49,0x21,0x49,0x41,0x49,0x81,0x49,0xFF,
0x49,0x89,0x49,0x89,0x49,0x89,0x7F,0x89,0x00,0x89,0x00,0x81,0x00,0x81,0x00,0x00,/*"是",34*/
/* (16 X 16 , 宋体 ) */

0x20,0x01,0x10,0x01,0x2C,0x01,0xE7,0x7F,0x24,0x21,0x24,0x11,0x00,0x00,0xFE,0xFF,
0x92,0x40,0x92,0x23,0x92,0x0C,0x92,0x14,0xFE,0x22,0x00,0x41,0x00,0x40,0x00,0x00,/*"银",35*/
/* (16 X 16 , 宋体 ) */

0x10,0x04,0x60,0x04,0x02,0x7E,0x8C,0x01,0x00,0x00,0x04,0x00,0xE4,0x0F,0x24,0x04,
0x24,0x04,0xE4,0x0F,0x04,0x40,0x04,0x80,0xFC,0x7F,0x04,0x00,0x04,0x00,0x00,0x00,/*"河",36*/
/* (16 X 16 , 宋体 ) */

0x84,0x08,0x04,0x0B,0x14,0xF8,0x64,0x04,0x0F,0x03,0x04,0x04,0x84,0x04,0x44,0xFA,
0xB4,0x4A,0x24,0x49,0x2F,0x49,0xA4,0x4A,0x64,0xFA,0x04,0x04,0x04,0x04,0x00,0x00,/*"落",37*/
/* (16 X 16 , 宋体 ) */

0x00,0x80,0x10,0x40,0x10,0x20,0x10,0x18,0x10,0x07,0xFF,0x00,0x10,0x00,0x10,0x00,
0x10,0x00,0x10,0x00,0xF0,0x3F,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x78,0x00,0x00,/*"九",38*/
/* (16 X 16 , 宋体 ) */

0x40,0x80,0x40,0x80,0x42,0x40,0x42,0x20,0x42,0x10,0x42,0x0C,0x42,0x03,0xFE,0x00,
0x42,0x03,0x42,0x0C,0x42,0x10,0x42,0x20,0x42,0x40,0x40,0x80,0x40,0x80,0x00,0x00,/*"天",39*/
/* (16 X 16 , 宋体 ) */

0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x24,0x00,0x24,0x00,0x18,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"。",40*/
/* (16 X 16 , 宋体 ) */
};

void send(uchar dat595);
void delay(uint n);
void disp(uint k);
void dispmove(void);

main()
{
   while(1)
 {
   dispmove();
 }
}

void send(uchar dat595)
{
uchar dat=dat595;
uint i;
for(i=0;i<8;i++)
{
dat<<=1;
ds=CY;
sh_cp=0;
sh_cp=1;
}
}

void delay(uint n)
{
  uint i,j;
for(i=0;i<n;i++)
  for(j=0;j<100;j++);
}

void disp(uint k)
{
uchar i,j,m,row;
uint g;
for(j=0;j<5;j++)
{
row=0x08;
for(i=0;i<16;i++)
{
st_cp=0;
for(m=6;m>0;m--)
{
g=2*i+2*k+m*32-32;
send(tab[g+1]);
send(tab[g]);
}
P1=row;
row++;
st_cp=1;
delay(1);
}
}
}

void dispmove(void)
{
uint k,j;
for(k=0;k<16*(num-3);k++)
{
disp(k);
}
for(k=16*(num-3);k>0;k--)
{
disp(k);
}
for(j=0;j<1;j++)
{
  for(k=16;k>0;k--)
{
  disp(16*6*j);
}
}
}

二、总结

今天主要讲了基于51单片机的点阵式LED滚动显示屏设计。

感谢你的观看!

在这里插入图片描述


原文地址:https://blog.csdn.net/qq_44836335/article/details/140572445

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!