点阵16*32综合(间断、上移、下移、左移、右移、左拉、右拉)C程序,硬件电路:行驱动74HC154+S8550三极管,列驱动74HC595,具体原理图祥见:http://www.51hei.com/mcu/1522.html
具体视频效果祥见:http://www.tudou.com/programs/view/8qoTrWwtGzg/本文引用地址:http://www.eepw.com.cn/article/201611/323401.htm
程序代码下载:http://www.51hei.com/f/dz88.rar
#include#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
};//字模数组
ucharcode 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
};
ucharcode 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;//将数移走一位
}
}