点阵乱码问题
时间:10-02
整理:3721RD
点击:
/*要求用两个74HC595控制一个8*8点阵*/
#include <reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
sbit SH_CP1 = P1^0;
sbit DS1 = P1^1;
sbit ST_CP1 = P1^2;
sbit SH_CP2 = P1^3;
sbit DS2 = P1^4;
sbit ST_CP2 = P1^5;
uchar temp1,temp2;
char code tab[]={0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f,0xfe};
uchar code Digit[]=
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00,
0x00,0x00,0x00,0x00,0x21,0x7f,0x01,0x00,
0x00,0x00,0x27,0x45,0x45,0x45,0x39,0x00,
0x00,0x00,0x22,0x49,0x49,0x49,0x36,0x00,
0x00,0x00,0x0c,0x14,0x24,0x7f,0x04,0x00,
0x00,0x00,0x72,0x51,0x51,0x51,0x4e,0x00,
0x00,0x00,0x3e,0x49,0x49,0x49,0x26,0x00,
0x00,0x00,0x40,0x40,0x40,0x4f,0x70,0x00,
0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00,
0x00,0x00,0x32,0x49,0x49,0x49,0x3e,0x00
};
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
void In_1_595() //把数据锁入到U3寄存器
{
uchar i;
for(i=0;i<8;i++)
{
temp1 <<= 1;
DS1 = CY;
SH_CP1 = 1;
_nop_();
_nop_();
SH_CP1 = 0;
}
}
void Out_1_595() //把595的数据输出到8位并行口上
{
ST_CP1 = 0;
_nop_();
ST_CP1 = 1;
_nop_();
ST_CP1 = 0;
}
void In_2_595() //把数据锁入到U4寄存器
{
uchar i;
for(i=0;i<8;i++)
{
temp2 <<= 1;
DS2 = CY;
SH_CP2 = 1;
_nop_();
_nop_();
SH_CP2 = 0;
}
}
void Out_2_595() //把595的数据输出到8位并行口上
{
ST_CP2 = 0;
_nop_();
ST_CP2 = 1;
_nop_();
ST_CP2 = 0;
}
void main()
{
uchar t,n,num,i=0;
while(1)
{
for(n=0;n<88;n++)
{
for(t=0;t<20;t++) //控制流动速度
{
for(num=n;num<8+n;num++) //流动显示效果
{
temp1=(Digit[num]); //输入数据
In_1_595();
Out_1_595();
delayms(1); //延时程序,调整扫描频率
temp2=( tab); //扫描
if(++i==8)i=0;
In_2_595();
Out_2_595();
}
}
}
}
}
问题:用8X8点阵显示0~9数字流动,为什么9后面会出现乱码?
移动结束以后立马停止,从头再来,或者用空白填充,不然显示乱码!
恩,谢谢哈
小编分享一下电路图啦 谢谢啦
啊啊啊啊啊!~知道啦~
怎么用空白填充,