2个74HC138芯片驱动的16*16led点阵显示仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
制作出来的实物图:
单片机源程序如下:
- #include<reg51.h>
- #include<intrins.h>
- #define uchar unsigned char
- #define uint unsigned int
- #define data1 P0
- #define data2 P2
- sbit s1=P3^6;
- sbit s2=P3^7;
- bit fangxiang;
- uint alt=0,net=0,sl=288;
- bit mode;
- uchar code tab[]={
- // (0) (1) 老(2) 师(3) ,(4) 你(5) 辛(6) 苦(7) 了(8) !
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",0*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",1*/
- 0x02,0x10,0x22,0x10,0x22,0x20,0x22,0x20,0x22,0x40,0x22,0x7C,0xFE,0x92,0x23,0x12,
- 0x23,0x22,0x22,0x22,0x26,0x42,0x2A,0x42,0x72,0x02,0x22,0x0E,0x02,0x00,0x00,0x00,/*"老",2*/
- 0x00,0x02,0x3F,0xE4,0x00,0x08,0x00,0x70,0xFF,0x80,0x00,0x00,0x4F,0xF0,0x48,0x00,
- 0x48,0x00,0x48,0x00,0x7F,0xFF,0x48,0x00,0x48,0x20,0x48,0x10,0x4F,0xE0,0x00,0x00,/*"师",3*/
- 0x00,0x00,0x00,0x00,0x00,0x1A,0x00,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*",",4*/
- 0x01,0x00,0x02,0x04,0x0C,0x1C,0x3F,0xC0,0xC0,0x1C,0x09,0x02,0x16,0x02,0x60,0x92,
- 0x20,0x4A,0x2F,0x82,0x20,0x02,0x24,0x0E,0x22,0x00,0x31,0x90,0x20,0x0C,0x00,0x00,/*"您",5*/
- 0x01,0x00,0x21,0x20,0x21,0x20,0x29,0x20,0x25,0x20,0x23,0x20,0xA1,0x20,0x61,0xFF,
- 0x21,0x20,0x23,0x20,0x25,0x20,0x29,0x20,0x21,0x20,0x21,0x00,0x01,0x00,0x00,0x00,/*"辛",6*/
- 0x02,0x00,0x22,0x00,0x22,0x00,0x22,0x7E,0x22,0x44,0xFA,0x44,0x22,0x44,0x2F,0xC4,
- 0x22,0x44,0x22,0x44,0xFA,0x44,0x22,0x7E,0x22,0x00,0x22,0x00,0x22,0x00,0x00,0x00,/*"苦",7*/
- 0x00,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x40,0x02,0x40,0x01,0x4F,0xFE,
- 0x48,0x00,0x50,0x00,0x50,0x00,0x60,0x00,0x60,0x00,0x40,0x00,0x00,0x00,0x00,0x00,/*"了",8*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xFA,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"!",9*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",14*/
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*" ",15*/
- };
- void delay(uint z) //延时子函数
- {
- uchar x;
- for(;z>0;z--)
- for(x=110;x>0;x--);
- }
- void xianshi() //显示
- {
- uchar aa,i;
- for(i=0;i<16;i++)
- {
- P1=i; //列扫描
- data1=tab[net+aa]; //取出上8行数据输出
- aa++;
- data2=tab[net+aa]; //取出下8行数据输出
- aa++;
- delay(5); //延时
- data1=0; //清屏
- data2=0; //清屏
- P1=0x00; //消除余辉
- if(aa>30) aa=0; //字模地址
- }
-
- }
- void main() //主函数
- {
- ET1=1; //使能定时器0
- EA=1; //开启总中断
- TR1=1; //开始计数
- while(1) //无限循环
- {
- xianshi(); //显示
- if(s1==0) //检测按键
- {
- delay(30); //延时消抖
- TR1=~TR1; //按下暂停 ,暂按继续
- while(!s1)xianshi();
- delay(30);
- }
- if(s2==0) //检测按键
- {
- delay(30); //延时消抖
- fangxiang=~fangxiang; //方向取反
- while(!s2)xianshi();
- delay(30);
- }
- }
- }
-
- void timer1() interrupt 3
- {
- alt++;
- if(alt==10) //到一定的时间加以实现左移
- {
- alt=0;
- if(fangxiang==0) //如果是正向 正向移动
- {
- net=net+2;
- if(net>sl) //字移动数量
- net=0;
- }
- else //否则反向移动
- {
- net=net-2;
- if(net<2)
- net=sl; //字移动数量
- }
- }
-
- }
复制代码
所有资料51hei提供下载:
71-138LED点阵.zip
(103.22 KB, 下载次数: 224)
|