hlzhaowu 发表于 2013-3-13 20:53
楼主能否说得具体一点,最好是把程序贴上来
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
#define SCAN P2 //行驱动接到P2
sbit SHCP=P1^0; //595 CLK
sbit STCP=P1^1; //595 STR
sbit DR=P1^5; //绿色
sbit DG=P1^3; //红色
sbit ENT=P1^4; //595 OE/G
uint word; //字模计数器
uchar move; //列指针
uchar line; //行指针
uchar speed=10; //设定移动速度
uint stay=100; //设定停留时间
uchar BUF[100];//缓存数组
uchar code disp[];
uchar code tian[];
uchar code qi[];
uchar code qing[];
uchar code yi[]; //字模数组
void delay(void)
{ uchar i;
for(i=0;i<200;i++);
}
/********************装载一线点阵数据********************/
void loadline()
{
char s;
for(s=0;s<18;s++) //s为要显示的字数+1
{
if (s<6)
{
BUF[2*s]=disp[word+32*s+2*line];
BUF[2*s+1]=disp[word+1+32*s+2*line];
}
else
{
if(6<s<8)
{
BUF[2*s]=tian[word+32*s+2*line] ;
BUF[2*s+1]=tian[word+1+32*s+2*line];
}
else
{
BUF[2*s]=qi[word+32*s+2*line] ;
BUF[2*s+1]=qi[word+1+32*s+2*line];
}
}
}
}
/********************发送一线移动数据********************/
void sendline()
{
char s,p;
uchar inc,k,j;
if(move<8)
inc=0;
else inc=1;
for(s=0+inc;s<=7+inc;s++)
{
if(move<8)
j=move;
else j=move-8;
k=(BUF<<j)|(BUF[s+1]>>(8-j)); //字模左边字节左移j位,右边字节右移j位,2者相或
for(p=0;p<8;p++)
{ SHCP=0;
if(k&0x80) DG=1; //选择红色显示
else DG=0;
k=k<<1; //595时钟信号,产生脉冲
SHCP=1;
}
//左移一位
}
}
void main()
{
char s,p;
uint k;
uchar i,y=0;
move=0;
word=0;
ENT=0;
ENT=1; //清屏
while(1)
{
while(word<289) //(4+5)*32=288
{
while(move<16) //数据移位
{
for(i=0;i<2;i++) //移动速度
{
for(line=0;line<16;line++) //行扫描
{
loadline(); //装载一线点阵数据
sendline(); //发送一线移动数据
SCAN=line; //显示第line行
STCP=1; //锁存为高,595锁存信号
STCP=0;
}
}
move=move+1; //移动一步(一位)
}
move=0;
word=word+32; //下一个字
}
word=0;
}
}
uchar code disp[]={
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,/*前面三字位置空白显示*/
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xFE,0xFF,0xFE,0xFF,0xFD,0x7F,0xFB,0xBF,0xF7,0xDF,0xED,0xEF,0xDE,0x71,0x3F,0x7B,
0xFF,0xFF,0xE0,0x0F,0xFF,0xEF,0xFF,0xDF,0xFF,0xDF,0xFF,0xBF,0xFF,0x7F,0xFE,0xFF,//今
0xFF,0xF7,0x80,0x03,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFB,0x00,0x01,0xFE,0xFF,
0xFD,0x7F,0xFD,0x7F,0xFB,0xBF,0xFB,0xBF,0xF7,0xDF,0xEF,0xEF,0xDF,0xF1,0x3F,0xFB,//天
0xFF,0xF7,0x80,0x03,0xFE,0xFF,0xFE,0xFF,0xFE,0xFF,0xFE,0xFB,0x00,0x01,0xFE,0xFF,
0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