STC89C52单片机74HC595驱动LED8*8点阵

STC89C52单片机74HC595驱动LED8*8点阵。我只知道一点C语言的知识,请问74HC595编程时,如何产生连续的上升沿,让位数据一个一个(编码是以16进制的数... STC89C52单片机74HC595驱动LED8*8点阵。我只知道一点C语言的知识,请问74HC595编程时,如何产生连续的上升沿,让位数据一个一个(编码是以16进制的数组)地准确储存移位。 展开
 我来答
胡经豪
推荐于2016-01-16
知道答主
回答量:26
采纳率:100%
帮助的人:9.6万
展开全部

我做过16*16点阵用了4片595 级联 以下有代码 希望能帮助楼主

#include <reg52.h>

#define uchar unsigned char

#define uint unsigned int

sbit SH_CP=P1^2;

sbit DS=P1^0;

sbit ST_CP=P1^1;

uchar code tab[ ]=

{ 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,0x01,0x00,0x06,0x1F,0xF8,0x11,0x00,0x11,0x08,0x11,0x04,0x11,0xF8,0x10,0x01,

0x10,0x02,0xFF,0x84,0x10,0x68,0x90,0x18,0x50,0x64,0x13,0x82,0x10,0x1F,0x00,0x00,/*"成",0*/

0x04,0x20,0x24,0x40,0x24,0xFF,0x25,0x92,0xFE,0x92,0x24,0x92,0x2C,0x92,0x14,0xFF,

0x64,0x00,0x04,0x00,0x7F,0xFF,0x40,0x10,0x44,0x08,0x5B,0x10,0x60,0xE0,0x00,0x00,/*"都",1*/

0x20,0x04,0x21,0x06,0x21,0x04,0x3F,0xF8,0x21,0x08,0x21,0x08,0x00,0x02,0x7F,0x22,

0x49,0x22,0x49,0x22,0x7F,0xFE,0x49,0x22,0x49,0x22,0x7F,0x22,0x00,0x02,0x00,0x00,/*"理",2*/

0x00,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x3F,0xFC,

0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x00,0x04,0x00,0x00,/*"工",3*/

0x04,0x01,0x04,0x01,0x04,0x02,0x04,0x04,0x04,0x08,0x04,0x30,0x04,0xC0,0xFF,0x00,

0x04,0xC0,0x04,0x30,0x04,0x08,0x04,0x04,0x04,0x02,0x04,0x01,0x04,0x01,0x00,0x00,/*"大",4*/

0x02,0x20,0x0C,0x20,0x88,0x20,0x69,0x20,0x09,0x20,0x09,0x22,0x89,0x21,0x69,0x7E,

0x09,0x60,0x09,0xA0,0x19,0x20,0x28,0x20,0xC8,0x20,0x0A,0x20,0x0C,0x20,0x00,0x00,/*"学",5*/

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*/

};


//列选 因为595的送数据后高低位倒置,所以数组中的数据预先倒置。如:1111 1110 应为 0111 1111

uchar a[ ]={0x7f,0xff,0xbf,0xff,0xdf,0xff,0xef,0xff,0xf7,0xff,0xfb,0xff,0xfd,0xff,0xfe,0xff,

0xff,0x7f,0xff,0xbf,0xff,0xdf,0xff,0xef,0xff,0xf7,0xff,0xfb,0xff,0xfd,0xff,0xfe,};

void delay(uint z)

{

uint x;

for(;z>0;z--)

for(x=11;x>0;x--);

}

void WriteByte(uchar dat)

{

uchar k;

for(k=0;k<8;k++)

{

dat=dat>>1;

DS=CY;

SH_CP=0;

SH_CP=1;

}

}

void main()

{

uint num,temp,n,m;


while(1)

{


for(n=0;n<112;n++)


for(m=0;m<8;m++) //重复显示8次

{

temp=0;// 不加此条,流动飞快

for(num=n;num<16+n;num++)


{

WriteByte(tab[2*num+1]);

WriteByte(tab[2*num+0]);


WriteByte(a[2*temp+1]); //8~15列选

WriteByte(a[2*temp]); //0~7列选

temp++;

if(temp==16)

temp=0;

ST_CP=0;

ST_CP=1;

delay(2);


}

}

}

}

匿名用户
2012-06-27
展开全部
void _74HC595_BYTE_WRITE(unsigned char Byte)
{
unsigned char I;
for (I = 0;I<8;I++)
{
_74hc595data = (bit)(Byte & 0x80)
_74hc595clk = 0;
_74hc595clk = 1;
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式