点阵16*32综合(间断、上移、下移、左移、右移、左拉、右拉)C程序,硬件电路:行驱动74HC154+S8550三极管,列驱动74HC595,具体原理图祥见:http://www.51hei.com/mcu/1522.html
具体视频效果祥见:http://www.tudou.com/programs/view/8qoTrWwtGzg/
程序代码下载:http://www.51hei.com/f/dz88.rar
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
#define LINE P0//定义行线IO口,即74HC154控制端
#define shudu 4//字移动的速度
sbit DATA=P1^4;//74HC595数据端
sbit CLK=P1^5;//74HC595移位脉冲端
sbit CLKR=P1^6;//74HC595数据锁存端
uchar move;//移动几位变量
uchar line,ji;//行变量
uint word;//字节变量
uchar BUF[6];//4组缓存数组以便动态更改数据
uchar code table[]={
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,0x10,0x3F,0xF8,0x04,0x10,0x04,0x14,0xFF,0xFE,0x04,0x10,0x04,0x10,
0x3F,0xF0,0x04,0x10,0x04,0x00,0x08,0x00,0x08,0x00,0x10,0x00,0x20,0x00,0x40,0x00,
0x01,0x00,0x01,0x08,0x7F,0xFC,0x01,0x00,0x3F,0xF8,0x01,0x00,0xFF,0xFE,0x00,0x10,
0x1F,0xF8,0x10,0x10,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0x10,0x50,0x10,0x20,
0x01,0x00,0x01,0x00,0x01,0xF8,0x01,0x00,0x01,0x10,0x1F,0xF8,0x10,0x10,0x10,0x10,
0x10,0x10,0x1F,0xF0,0x10,0x10,0x01,0x10,0x28,0x88,0x24,0x44,0x44,0x44,0x00,0x00,
0x00,0x80,0xF8,0x80,0x88,0x80,0x97,0xFC,0xA1,0x00,0x91,0x40,0x8A,0x40,0x8F,0xFC,
0x88,0x40,0xA8,0x40,0x97,0xFE,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,0x80,0x40,
0x24,0x04,0x34,0x04,0x24,0x24,0x3F,0xA4,0x44,0x24,0x04,0x24,0x7F,0xA4,0x04,0x24,
0x3F,0xA4,0x24,0xA4,0x24,0xA4,0x24,0xA4,0x24,0x84,0x27,0x84,0x05,0x14,0x04,0x08,
0x08,0x80,0x0C,0x80,0x09,0x00,0x13,0xFE,0x12,0x80,0x34,0x88,0x50,0xFC,0x90,0x80,
0x10,0x80,0x10,0x84,0x10,0xFE,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,0x10,0x80,
0x00,0xA0,0x00,0x90,0x00,0x80,0x3F,0xFE,0x20,0x80,0x20,0x80,0x3E,0x88,0x22,0x8C,
0x22,0x48,0x22,0x50,0x22,0x20,0x2A,0x60,0x44,0x92,0x41,0x0A,0x86,0x06,0x00,0x02,
0x00,0x20,0x00,0x20,0x7F,0x20,0x08,0x20,0x0B,0xFC,0x08,0x24,0x08,0x24,0x08,0x44,
0x09,0x44,0x0E,0x44,0xF0,0x84,0x40,0x84,0x01,0x04,0x02,0x78,0x04,0x10,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
};//字模数组
uchar code table1[]={
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,
/* 当前所选字体下一个汉字对应的点阵为: 宽度x高度=32x16, 调整后为: 32x16*/
0x00,0x00,0x01,0x00,0x3F,0xF8,0x01,0x00,0x02,0x08,0x3F,0xF8,0x02,0x08,0x01,0x00,
0x7F,0xFE,0x1F,0xF0,0x02,0x08,0x01,0x00,0x02,0x08,0xFF,0xFE,0x3F,0xF8,0x00,0x00,
0x02,0x08,0x1F,0xF0,0x02,0x00,0x10,0x10,0x04,0x00,0x1F,0xF0,0x04,0x00,0x10,0x10,
0x08,0x00,0x1F,0xF0,0x10,0x00,0x10,0x10,0x20,0x00,0x10,0x50,0x40,0x00,0x10,0x20,
/*; 当前所选字体下一个汉字对应的点阵为: 宽度x高度=32x16, 调整后为: 32x16*/
0x01,0x00,0x00,0x80,0x01,0x00,0xF8,0x80,0x01,0xF8,0x88,0x80,0x01,0x00,0x97,0xFC,
0x01,0x10,0xA1,0x00,0x1F,0xF8,0x91,0x40,0x10,0x10,0x8A,0x40,0x10,0x10,0x8F,0xFC,
0x10,0x10,0x88,0x40,0x1F,0xF0,0xA8,0x40,0x10,0x10,0x97,0xFE,0x01,0x10,0x80,0x40,
0x28,0x88,0x80,0x40,0x24,0x44,0x80,0x40,0x44,0x44,0x80,0x40,0x00,0x00,0x80,0x40,
/*; 当前所选字体下一个汉字对应的点阵为: 宽度x高度=32x16, 调整后为: 32x16*/
0x24,0x04,0x08,0x80,0x34,0x04,0x0C,0x80,0x24,0x24,0x09,0x00,0x3F,0xA4,0x13,0xFE,
0x44,0x24,0x12,0x80,0x04,0x24,0x34,0x88,0x7F,0xA4,0x50,0xFC,0x04,0x24,0x90,0x80,
0x3F,0xA4,0x10,0x80,0x24,0xA4,0x10,0x84,0x24,0xA4,0x10,0xFE,0x24,0xA4,0x10,0x80,
0x24,0x84,0x10,0x80,0x27,0x84,0x10,0x80,0x05,0x14,0x10,0x80,0x04,0x08,0x10,0x80,
/*; 当前所选字体下一个汉字对应的点阵为: 宽度x高度=32x16, 调整后为: 32x16*/
0x00,0xA0,0x00,0x20,0x00,0x90,0x00,0x20,0x00,0x80,0x7F,0x20,0x3F,0xFE,0x08,0x20,
0x20,0x80,0x0B,0xFC,0x20,0x80,0x08,0x24,0x3E,0x88,0x08,0x24,0x22,0x8C,0x08,0x44,
0x22,0x48,0x09,0x44,0x22,0x50,0x0E,0x44,0x22,0x20,0xF0,0x84,0x2A,0x60,0x40,0x84,
0x44,0x92,0x01,0x04,0x41,0x0A,0x02,0x78,0x86,0x06,0x04,0x10,0x00,0x02,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
};
uchar code table2[]={
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,
/*; 当前所选字体下一个汉字对应的点阵为: 宽度x高度=32x16, 调整后为: 32x16*/
0x00,0xA0,0x00,0x20,0x00,0x90,0x00,0x20,0x00,0x80,0x7F,0x20,0x3F,0xFE,0x08,0x20,
0x20,0x80,0x0B,0xFC,0x20,0x80,0x08,0x24,0x3E,0x88,0x08,0x24,0x22,0x8C,0x08,0x44,
0x22,0x48,0x09,0x44,0x22,0x50,0x0E,0x44,0x22,0x20,0xF0,0x84,0x2A,0x60,0x40,0x84,
0x44,0x92,0x01,0x04,0x41,0x0A,0x02,0x78,0x86,0x06,0x04,0x10,0x00,0x02,0x00,0x00,
/*; 当前所选字体下一个汉字对应的点阵为: 宽度x高度=32x16, 调整后为: 32x16*/
0x24,0x04,0x08,0x80,0x34,0x04,0x0C,0x80,0x24,0x24,0x09,0x00,0x3F,0xA4,0x13,0xFE,
0x44,0x24,0x12,0x80,0x04,0x24,0x34,0x88,0x7F,0xA4,0x50,0xFC,0x04,0x24,0x90,0x80,
0x3F,0xA4,0x10,0x80,0x24,0xA4,0x10,0x84,0x24,0xA4,0x10,0xFE,0x24,0xA4,0x10,0x80,
0x24,0x84,0x10,0x80,0x27,0x84,0x10,0x80,0x05,0x14,0x10,0x80,0x04,0x08,0x10,0x80,
/*; 当前所选字体下一个汉字对应的点阵为: 宽度x高度=32x16, 调整后为: 32x16*/
0x01,0x00,0x00,0x80,0x01,0x00,0xF8,0x80,0x01,0xF8,0x88,0x80,0x01,0x00,0x97,0xFC,
0x01,0x10,0xA1,0x00,0x1F,0xF8,0x91,0x40,0x10,0x10,0x8A,0x40,0x10,0x10,0x8F,0xFC,
0x10,0x10,0x88,0x40,0x1F,0xF0,0xA8,0x40,0x10,0x10,0x97,0xFE,0x01,0x10,0x80,0x40,
0x28,0x88,0x80,0x40,0x24,0x44,0x80,0x40,0x44,0x44,0x80,0x40,0x00,0x00,0x80,0x40,
/* 当前所选字体下一个汉字对应的点阵为: 宽度x高度=32x16, 调整后为: 32x16*/
0x00,0x00,0x01,0x00,0x3F,0xF8,0x01,0x00,0x02,0x08,0x3F,0xF8,0x02,0x08,0x01,0x00,
0x7F,0xFE,0x1F,0xF0,0x02,0x08,0x01,0x00,0x02,0x08,0xFF,0xFE,0x3F,0xF8,0x00,0x00,
0x02,0x08,0x1F,0xF0,0x02,0x00,0x10,0x10,0x04,0x00,0x1F,0xF0,0x04,0x00,0x10,0x10,
0x08,0x00,0x1F,0xF0,0x10,0x00,0x10,0x10,0x20,0x00,0x10,0x50,0x40,0x00,0x10,0x20,
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(uchar z)
{
uchar x,y;
for(x=8;x>0;x--)
for(y=z;y>0;y--);
}
/********************************/
/**74HC595移位寄存器送数子函数***/
/********************************/
void song(uchar z)//带参数函数
{
uchar num,hang;//定义变量
hang=z;//将形参给变量
for(num=0;num<8;num++)//移动8次将数据发送完毕
{
if(hang&0x01==1)//将高7位屏蔽掉,保留最低位判断
DATA=1;//为1就将74HC595数据端置1
else
DATA=0;//否则给0
CLK=0;//上升沿送走数据
CLK=1;//高电平形成上升沿
hang>>=1;//将数移走一位
}
}
/********************************/
/*装一线数据子函数(即一行数据)*/
/********************************/
void yixian()
{
uchar s;
for(s=0;s<3;s++)/*循环2次,得到第1个字(代码存在数组1与2中)
与第2个字(代码存在数组2与3中)的某一行数值*/
{
BUF[s*2]=table[word+(32*s)+(line*2)];//左半屏代码,line表示行数,word表示字数
BUF[s*2+1]=table[word+(32*s+1)+(line*2)];//右半屏代码
}
}
/*************************************************************************/
/*******************************间断子程序*********************************/
/*************************************************************************/
void jian()
{
uchar j;
while(word<80)//循环80次一个字16次即5*16
{
for(j=0;j<50;j++)//1个字显示的速度
{
ji=word;//将变量给它
for(line=0;line<16;line++)//循环16次得到一整屏字
{
song(~table1[ji*4+3]);//发送第2个字右半屏数
song(~table1[ji*4+2]);//发送第2个字左半屏的数
song(~table1[ji*4+1]);//发送第1个右半屏的数
song(~table1[ji*4]);//发送第1个字左半屏的数
ji++;//接着发下一行
CLKR=1;//在74HC595处锁存起来
CLKR=0;
CLKR=1;
LINE=line;//打开行
delay(10);
}
}
word+=16;//显示下一个字
}
}
/*************************************************************************/
/*******************************上移子程序*********************************/
/*************************************************************************/
void shang()
{
uchar j;
while(word<80)//循环80次一个字16次即5*16
{
for(j=0;j<10;j++)//1个字显示的速度
{
ji=word;//将变量给它
for(line=0;line<16;line++)//循环16次得到一整屏字
{
song(~table1[ji*4+3]);//发送第2个字右半屏数
song(~table1[ji*4+2]);//发送第2个字左半屏的数
song(~table1[ji*4+1]);//发送第1个右半屏的数
song(~table1[ji*4]);//发送第1个字左半屏的数
ji++;//接着发下一行
CLKR=1;//在74HC595处锁存起来
CLKR=0;
CLKR=1;
LINE=line;//打开行
delay(5);
}
}
word+=1;//移一位形成上移
}
}
/*************************************************************************/
/*******************************下移子程序*********************************/
/*************************************************************************/
void xia()
{
uchar j;
while(word>0)//循环80次一个字16次即5*16
{
for(j=0;j<10;j++)//1个字显示的速度
{
ji=word;//将变量给它
for(line=0;line<16;line++)//循环16次得到一整屏字
{
song(~table2[ji*4+3]);//发送第2个字右半屏数
song(~table2[ji*4+2]);//发送第2个字左半屏的数
song(~table2[ji*4+1]);//发送第1个右半屏的数
song(~table2[ji*4]);//发送第1个字左半屏的数
ji++;//接着发下一行
CLKR=1;//在74HC595处锁存起来
CLKR=0;
CLKR=1;
LINE=line;//打开行
delay(5);
}
}
word-=1;//移一位形成上移
}
}
/*************************************************************************/
/*******************************左移子程序*********************************/
/*************************************************************************/
/*将一行数据转换出来,然后显示*/
/********************************/
void yipai()
{
uchar temp,yi;
if(move<8)//处理移动次数小于8次的部分
{
yi=move;
temp=(BUF[3]<<yi)|(BUF[4]>>(8-yi));/*将第2个字的右半屏数左移yi次,
然后或上第3个字左半屏的8-yi次数,注此句是处理第2个字右半屏的数*/
song(~temp);//发送给74HC595
temp=(BUF[2]<<yi)|(BUF[3]>>(8-yi));/*将第2个字的左半屏数左移yi次,
然后或上第2个字右半屏的8-yi次数,注此句是处理第2个字左半屏的数*/
song(~temp);//发送给74HC595
temp=(BUF[1]<<yi)|(BUF[2]>>(8-yi));/*将第1个字的右半屏数左移yi次,
然后或上第2个字左半屏的8-yi次数,注此句是处理第1个字右半屏的数*/
song(~temp);//发送给74HC595
temp=(BUF[0]<<yi)|(BUF[1]>>(8-yi));/*将第1个字的左半屏数左移yi次,
然后或上第1个字右半屏的8-yi次数,注此句是处理第1个字左半屏的数*/
song(~temp);//发送给74HC595
}
else//处理移动次数小于8次以外的部分
{
yi=move-8;
temp=(BUF[4]<<yi)|(BUF[5]>>(8-yi));/*将第3个字的左半屏数左移yi次,
然后或上第3个字右半屏的8-yi次数,注此句是处理第2个字右半屏的数*/
song(~temp);//发送给74HC595
temp=(BUF[3]<<yi)|(BUF[4]>>(8-yi));/*将第2个字的右半屏数左移yi次,
然后或上第3个字左半屏的8-yi次数,注此句是处理第2个字左半屏的数*/
song(~temp);//发送给74HC595
temp=(BUF[2]<<yi)|(BUF[3]>>(8-yi));/*将第2个字的左半屏数左移yi次,
然后或上第2个字右半屏的8-yi次数,注此句是处理第1个字右半屏的数*/
song(~temp);//发送给74HC595
temp=(BUF[1]<<yi)|(BUF[2]>>(8-yi));/*将第1个字的右半屏数左移yi次,
然后或上第2个字左半屏的8-yi次数,注此句是处理第1个字左半屏的数*/
song(~temp);//发送给74HC595
}
}
void zou()
{
uchar i;
while(word<320)
{
for(move=0;move<16;move++)//要移多少位?
{
for(i=0;i<shudu;i++)//一字移动的速度
{
for(line=0;line<16;line++)//扫描16次,即完成一个字的移动
{
yixian();//调用一线子程序
yipai();//调用数据转换子程序
LINE=line;//打开行线,即174HC154行线端
CLKR=1;//在74HC595处锁存起来
CLKR=0;
CLKR=1;
}
}
}
word=word+32;//一个字显示完了,就显示下一个字
}
}
/*************************************************************************/
/*******************************右移子程序*********************************/
/*************************************************************************/
/*将一行数据转换出来,然后显示*/
/********************************/
void yipai2()
{
uchar temp,yi;
if(move<8)//处理移动次数小于8次的部分
{
yi=move;
temp=(BUF[0]<<(8-yi))|(BUF[1]>>yi);
song(~temp);//发送给74HC595
temp=(BUF[3]<<(8-yi))|(BUF[0]>>yi);
song(~temp);//发送给74HC595
temp=(BUF[2]<<(8-yi))|(BUF[3]>>yi);
song(~temp);//发送给74HC595
temp=(BUF[5]<<(8-yi))|(BUF[2]>>yi);
song(~temp);//发送给74HC595
}
else//处理移动次数小于8次以外的部分
{
yi=move-8;
temp=(BUF[3]<<(8-yi))|(BUF[0]>>yi);
song(~temp);//发送给74HC595
temp=(BUF[2]<<(8-yi))|(BUF[3]>>yi);
song(~temp);//发送给74HC595
temp=(BUF[5]<<(8-yi))|(BUF[2]>>yi);
song(~temp);//发送给74HC595
temp=(BUF[4]<<(8-yi))|(BUF[5]>>yi);
song(~temp);//发送给74HC595
}
}
void you()
{
uchar i;
while(word<320)
{
for(move=0;move<16;move++)//要移多少位?
{
for(i=0;i<shudu;i++)//一字移动的速度
{
for(line=0;line<16;line++)//扫描16次,即完成一个字的移动
{
yixian();//调用一线子程序
yipai2();//调用数据转换子程序
LINE=line;//打开行线,即174HC154行线端
CLKR=1;//在74HC595处锁存起来
CLKR=0;
CLKR=1;
}
}
}
word=word+32;//一个字显示完了,就显示下一个字
}
}
/*************************************************************************/
/*******************************左拉子程序*********************************/
/*************************************************************************/
/*将一行数据转换出来,然后显示*/
/********************************/
void yipai3()
{
uchar temp,yi;
if(move<8)//处理移动次数小于8次的部分
{
yi=move;
temp=(BUF[3]<<yi)|(BUF[4]>>(8-yi));/*将第2个字的右半屏数左移yi次,
然后或上第3个字左半屏的8-yi次数,注此句是处理第2个字右半屏的数*/
song(~temp);//发送给74HC595
temp=(BUF[2]<<yi)|(BUF[3]>>(8-yi));/*将第2个字的左半屏数左移yi次,
然后或上第2个字右半屏的8-yi次数,注此句是处理第2个字左半屏的数*/
song(~temp);//发送给74HC595
temp=(BUF[1]<<yi)|(BUF[2]>>(8-yi));/*将第1个字的右半屏数左移yi次,
然后或上第2个字左半屏的8-yi次数,注此句是处理第1个字右半屏的数*/
song(~temp);//发送给74HC595
temp=(BUF[0]<<yi)|(BUF[1]>>(8-yi));/*将第1个字的左半屏数左移yi次,
然后或上第1个字右半屏的8-yi次数,注此句是处理第1个字左半屏的数*/
song(~temp);//发送给74HC595
}
else//处理移动次数小于8次以外的部分
{
yi=move-8;
temp=(BUF[4]<<yi)|(BUF[5]>>(8-yi));/*将第3个字的左半屏数左移yi次,
然后或上第3个字右半屏的8-yi次数,注此句是处理第2个字右半屏的数*/
song(~temp);//发送给74HC595
temp=(BUF[3]<<yi)|(BUF[4]>>(8-yi));/*将第2个字的右半屏数左移yi次,
然后或上第3个字左半屏的8-yi次数,注此句是处理第2个字左半屏的数*/
song(~temp);//发送给74HC595
temp=(BUF[2]<<yi)|(BUF[3]>>(8-yi));/*将第2个字的左半屏数左移yi次,
然后或上第2个字右半屏的8-yi次数,注此句是处理第1个字右半屏的数*/
song(~temp);//发送给74HC595
temp=(BUF[1]<<yi)|(BUF[2]>>(8-yi));/*将第1个字的右半屏数左移yi次,
然后或上第2个字左半屏的8-yi次数,注此句是处理第1个字左半屏的数*/
song(~temp);//发送给74HC595
}
}
/********************************/
/*******将一行数据显示出来*******/
/********************************/
void zou3()
{
for(line=0;line<16;line++)//扫描16次,即完成一个字的移动
{
yixian();//调用一线子程序
yipai3();//调用数据转换子程序
LINE=line;//打开行线,即174HC154行线端
CLKR=1;//在74HC595处锁存起来
CLKR=0;
CLKR=1;
}
}
/********************************/
/*************左拉显示***********/
/********************************/
void zoula()
{
uchar i,ii,k;
while(word<320)//5个字*64=320
{
for(move=0;move<16;move++)//要移多少位?
{
for(i=0;i<2;i++)//一字移动的速度
{
zou3();//调用显示子程序
}
}
ii++;//将变量加1
if((ii%2)==0)//移完两个字才停下来
{
for(k=0;k<150;k++)//停下来时间
zou3();//一行显示子程序
}
word=word+32;//一个字显示完了,就显示下一个字
}
i=0;//标志位清0
}
/*************************************************************************/
/*******************************右拉子程序*********************************/
/*************************************************************************/
/*将一行数据转换出来,然后显示*/
/********************************/
void yipai5()
{
uchar temp,yi;
if(move<8)//处理移动次数小于8次的部分
{
yi=move;
temp=(BUF[0]<<(8-yi))|(BUF[1]>>yi);
song(~temp);//发送给74HC595
temp=(BUF[3]<<(8-yi))|(BUF[0]>>yi);
song(~temp);//发送给74HC595
temp=(BUF[2]<<(8-yi))|(BUF[3]>>yi);
song(~temp);//发送给74HC595
temp=(BUF[5]<<(8-yi))|(BUF[2]>>yi);
song(~temp);//发送给74HC595
}
else//处理移动次数小于8次以外的部分
{
yi=move-8;
temp=(BUF[3]<<(8-yi))|(BUF[0]>>yi);
song(~temp);//发送给74HC595
temp=(BUF[2]<<(8-yi))|(BUF[3]>>yi);
song(~temp);//发送给74HC595
temp=(BUF[5]<<(8-yi))|(BUF[2]>>yi);
song(~temp);//发送给74HC595
temp=(BUF[4]<<(8-yi))|(BUF[5]>>yi);
song(~temp);//发送给74HC595
}
}
void yihang()
{
for(line=0;line<16;line++)//扫描16次,即完成一个字的移动
{
yixian();//调用一线子程序
yipai5();//调用数据转换子程序
LINE=line;//打开行线,即174HC154行线端
CLKR=1;//在74HC595处锁存起来
CLKR=0;
CLKR=1;
}
}
void youla()
{
uchar i,j,ii;
while(word<320)
{
for(move=0;move<16;move++)//要移多少位?
{
for(ii=0;ii<2;ii++)//一字移动的速度
{
yihang();
}
}
i++;
if(i%2==0)
{
for(j=0;j<150;j++)
yihang();
}
word=word+32;//一个字显示完了,就显示下一个字
}
}
/********************************/
/************主程序*************/
/********************************/
void main()
{
while(1)
{
word=0;
jian();//间断
word=0;
shang();//上移
word=80;
xia();//下移
word=0;
zou();//左移
word=0;
you();//右移
word=0;
zoula();//左拉
word=0;
youla();//右拉
}
}