从8X8到16X16LED点阵流动显示154595驱动(51C)20120106更新4个595驱动行列很早以前做过汇编的8X8、16X16到24X24的流动显示,当时用的不是595,不易扩展。这次用51C写的,74HC154(16X16)作行,74HC595作列驱动的8X8和16X16的点阵,还可以很方便地再扩展。一、8X8先试试点亮一个8X8。试验结果,MATRIX-8X8-RED左旋90度上下翻转-GREEN右旋90度左右翻转安放在工作区。行控在左、列控(低电平控制)在右。图中可见,1、3列的0、2行点亮。取模软件用的是PCtoLCD2002取模方式阴码、逐列、顺向。仿真线路图仿真动画效果程序清单://595驱动8x8点阵0~9流动显示//20121211E:\DPJ_c\点阵DIY\8X8-左流动\8X8_C.c//74HC595是具有8位移位寄存器和一个存储寄存器,三态输出的功能。移位寄存器和存储器//是分别的时钟。数据在SHcp的上升沿输入,在STcp的上升沿进入存储寄存器。移位寄存器//有一个串行移位输入(Ds)和一个串行输出(Q7')。存储寄存器有一个并行8位的具备三//态的总线输出,当使能OE时(低电平),存储寄存器的数据输出到总线。#includereg51.h#includeintrins.h#defineucharunsignedchar#defineuintunsignedintsbitSH_CP=P2^0;sbitDS=P2^1;sbitST_CP=P2^2;ucharnum,temp,n,t;ucharcodetab[]=//PCTOLCD2002取模字体:Arial12x12//顺向、逐列、阴码MATRIX-8X8-RED左旋90度上下翻转//-GREEN右旋90度左右翻转{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*,0*/0x00,0x3E,0x41,0x41,0x41,0x41,0x3E,0x00,/*0,1*/0x00,0x00,0x20,0x20,0x7F,0x00,0x00,0x00,/*1,2*/0x00,0x21,0x43,0x45,0x45,0x49,0x31,0x00,/*2,3*/0x00,0x22,0x41,0x49,0x49,0x49,0x36,0x00,/*3,4*/0x00,0x04,0x0C,0x14,0x24,0x7F,0x04,0x00,/*4,5*/0x00,0x72,0x51,0x51,0x51,0x53,0x4E,0x00,/*5,6*/0x00,0x3E,0x6B,0x49,0x49,0x49,0x26,0x00,/*6,7*/0x00,0x40,0x41,0x42,0x4C,0x50,0x60,0x00,/*7,8*/0x00,0x36,0x49,0x49,0x49,0x49,0x36,0x00,/*8,9*/0x00,0x32,0x49,0x49,0x49,0x4B,0x3E,0x00,/*9,10*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*,11*/};voiddelay_ms(unsignedintms){ucharj;while(ms--)for(j=0;j123;j++);}voidWriteByte(uchardat){uchark;for(k=0;k8;k++){dat=dat1;DS=CY;SH_CP=0;SH_CP=1;}}voidmain(){while(1){for(n=0;n88;n++){for(t=0;t16;t++)//重复显示16次,让流动稍微缓慢{temp=0xfe;{for(num=n;num8+n;num++){WriteByte(tab[num+0]);P1=temp;ST_CP=0;ST_CP=1;delay_ms(1);temp=_crol_(temp,1);}}}}}}二、16X16仿真线路图,图中74159有误,应为74154。(点击可看大图)用4个8X8LED点阵组成一个16X16点阵。安放方法同8X8。因为扫描方式为逐列、顺向,595只有8路输出,所以先扫描左边的上、下,再右边的上、下。即左上半的0~7列和左下半的~7列,再右上半的8~15列和右下半的8~15列。仿真动画效果程序清单://4*8X8LED点阵流动显示0~9//20111216E:\DPJ_C\点阵DIY\4X8X8\4X8X8_C.c#includereg51.h#defineucharunsignedchar#defineuintunsignedintsbitSH_CP=P2^0;sbitDS=P2^1;sbitST_CP=P2^2;ucharcodetab[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*,0*/0x00,0x00,0x07,0xF0,0x1F,0xFC,0x3F,0xFE,0x38,0x0E,0x70,0x07,0x60,0x03,0x60,0x03,0x60,0x03,0x60,0x03,0x60,0x03,0x70,0x07,0x38,0x0E,0x3F,0xFE,0x1F,0xFC,0x07,0xF0,/*0,0*/0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x0C,0x00,0x1C,0x00,0x18,0x00,0x3F,0xFF,0x7F,0xFF,0x7F,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*1,1*/0x00,0x03,0x08,0x07,0x18,0x07,0x38,0x0F,0x30,0x0F,0x60,0x1B,0x60,0x13,0x60,0x33,0x60,0x23,0x60,0x63,0x60,0x43,0x60,0xC3,0x71,0x83,0x3F,0x83,0x3F,0x03,0x1E,0x03,/*2,2*/0x00,0x00,0x08,0x08,0x18,0x0C,0x38,0x0E,0x30,0x06,0x60,0x03,0x60,0x03,0x61,0x83,0x61,0x83,0x61,0x83,0x61,0x83,0x73,0xC7,0x3F,0xC6,0x3E,0xFE,0x1C,0x7C,0x00,0x38,/*3,3*/0x00,0x00,0x00,0x30,0x00,0x70,0x00,0xF0,0x01,0xB0,0x03,0x30,0x06,0x30,0x0C,0x30,0x18,0x30,0x30,0x30,0x7F,0xFF,0x7F,0xFF,0x7F,0xFF,0x00,0x30,0x00,0x30,0x00,0x30,/*4,4*/0x00,0x00,0x00,0x08,0x07,0x8C,0x7F,0x8E,0x7F,0x86,0x79,0x03,0x63,0x03,0x63,0x03,0x63,0x03,0x63,0x03,0x63,0x03,0x63,0x87,0x61,0x8E,0x61,0xFE,0x60,0xFC,0x00,0x78,/*5,5*/0x00,0x00,0x03,0xF0,0x0F,0xFC,0x1F,0xFE,0x3D,0x8E,0x31,0x87,0x73,0x03,0x63,0x03,0x63,0x03,0x63,0x03,0x63,0x03,0x63,0x87,0x71,0x8E,0x39,0xFE,0x38,0xFC,0x08,0x78,/*6,6*/0x00,0x00,0x60,0x00,0x60,0x00,0x60,0x00,0x60,0x01,0x60,0x03,0x60,0x0F,0x60,0x1F,0x60,0x7C,0x60,0xF8,0x63,0xE0,0x6F,0x80,0x7F,0x00,0x7C,0x00,0x78,0x00,0x60,0x00,/*7,7*/0x00,0x00,0x00,0x38,0x1C,0x7C,0x3E,0x7E,0x3E,0xE6,0x73,0xC7,0x63,0xC3,0x61,0x83,0x61,0x83,0x61,0x83,0x63,0xC3,0x73,0xC7,0x3E,0xE6,0x3E,0x7E,0x1C,0x7C,0x00,0x38,/*8,8*/0x00,0x00,0x0F,0x08,0x1F,0x8E,0x3F,0xCE,0x30,0xC7,0x70,0xE3,0x60,0x63,0x60,0x63,0x60,0x63,0x60,0x63,0x60,0x67,0x70,0xC6,0x38,0xDE,0x3F,0xFC,0x1F,0xF8,0x07,0xE0,/*9,9*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*,0*/};//顺向、逐列、阴码MICROSOFTSANSSERIF字宽32字高25MATRIX-8X8-GREEN右旋90度左右翻转//MATRIX-8X8-RED左旋90度上下翻转voiddelay_ms(unsignedintms){ucharj;while(ms--)for(j=0;j123;j++);}voidWriteByte(uchardat){uchark;for(k=0;k8;k++){dat=dat1;DS=CY;SH_CP=0;SH_CP=1;}}voidmain(){ucharnum,temp,n,m;while(1){for(n=0;n176;n++)//for(m=0;m8;m++)//重复显示8次{temp=0;//不加此条,流动飞快for(num=n;num16+n;num++){//WriteByte(tab[2*num+2*16+1]);//WriteByte(tab[2*num+2*16]);WriteByte(tab[2*num+1]);WriteByte(tab[2*num+0]);P1=temp;ST_CP=0;ST_CP=1;delay_ms(1);temp++;if(temp==16)temp=0;}}}}20120106更新不用74HC154,用2个595作列驱动,原2个595行驱动不变(如下图)。程序作小改动。//4*8X8LED点阵流动显示0~9//20120106E:\DPJ_C\点阵DIY\4X8X8\4X8X8_4x595\4X8X8_4x595.C#includereg51.h#defineucharunsignedchar#defineuintunsignedintsbitSH_CP=P2^0;sbitDS=P2^1;sbitST_CP=P2^2;ucharcodetab[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*,0*/0x00,0x00,0x07,0xF0,0x