据网上介绍可以在发送数据后先关掉行驱动,等数据锁存后再开行驱动,我试了一下,但是必须加延时,加了延时拖尾没有了,但是字体移动时,字体上半部分比下半部分要先移动,不加延时的话,又不能消隐,气死我了。我用的是74hc138两片做行驱动,595列驱动。
程序如下:
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit DS = P3^1;
sbit RCK = P3^2;
sbit SCK = P3^3;
sbit AOE = P1^0;
sbit BOE = P1^1;
uchar code wenzi[] = {
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit DS = P3^1;
sbit RCK = P3^2;
sbit SCK = P3^3;
sbit INH = P3^0;
sbit OE = P2^0;
uchar code wenzi[] = {
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,
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,
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,
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,
0x04,0x10,0x24,0x08,0x44,0x06,0x84,0x01,
0x64,0x82,0x9C,0x4C,0x40,0x20,0x30,0x18,
0x0F,0x06,0xC8,0x01,0x08,0x06,0x08,0x18,
0x28,0x20,0x18,0x40,0x00,0x80,0x00,0x00,/*"欢",0*/
0x40,0x00,0x40,0x40,0x42,0x20,0xCC,0x1F,
0x00,0x20,0x00,0x40,0xFC,0x4F,0x04,0x44,
0x02,0x42,0x00,0x40,0xFC,0x7F,0x04,0x42,
0x04,0x44,0xFC,0x43,0x00,0x40,0x00,0x00,/*"迎",1*/
0x40,0x80,0x40,0x80,0x42,0x40,0x44,0x20,
0x58,0x18,0xC0,0x07,0x40,0x00,0x7F,0x00,
0x40,0x00,0xC0,0x3F,0x50,0x40,0x48,0x40,
0x46,0x40,0x40,0x40,0x40,0x78,0x00,0x00,/*"光",2*/
0x00,0x00,0xF8,0x1F,0x00,0x00,0x00,0x00,
0xFF,0xFF,0x40,0x00,0x20,0x00,0x18,0x7F,
0x0F,0x21,0x18,0x21,0x68,0x3F,0x08,0x21,
0x08,0x21,0x08,0x7F,0x08,0x00,0x00,0x00,/*"临",3*/
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,
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,
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,
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
};
void delay(uint time)
{
uchar i;
for(i=0;i<time;i++);
}
void hc595_senddat(unsigned char dat)
{
unsigned char i;
dat=~dat;
for(i=0;i<8;i++)
{
DS=dat&0x80;
SCK=1;
SCK=0;
dat<<=1;
}
}
void main()
{
unsigned char i,n;
unsigned int k,m;
char j;
m=sizeof(wenzi);
SCK=0;
RCK=0;
OE = 1;
INH=0;
while(1)
{
for(k=0;k<m;k=k+2)
{
for(n=0;n<2;n++)
{
for(i=0;i<16;i++)
{
//delay(190);
for(j=3;j>=0;j--)
{
hc595_senddat(wenzi[(32*j+2*i+k)%m]);
hc595_senddat(wenzi[(32*j+2*i+1+k)%m]);
}
OE=1;
P1=i;
RCK=0;
RCK=1;
delay(15);
OE=0;
RCK=0;
//INH=0;
delay(40);
}
}
}
}
}
一周热门 更多>