一、硬件简介: 经过努力,总算完成了我曾经一向的愿望,点阵各种形式能独立原创出点阵屏各种形式:连续、上移、下移、左移、右移、上拉幕、下拉幕、左拉幕、右拉幕、左掩盖、右掩盖等等形式,我以为点阵只要是上移、左移会了,根本其它的都会了!一定要理解了,才算哟,太高兴了,现在和我们共享下了,我的硬件是:行是译码器74HC154+S8550,列是74HC595移位寄存器.
祥细视频如下http://www.tudou.com/programs/view/D0SCJyO4RBQ/
完好的程序源代码下载:http://www.51hei.com/f/dz854.rar
二、详细原理图见
电路介绍:http://www.51hei.com/mcu/1523.html
三、详细程序代码如下:
#include
#define uchar unsigned char
#define uint unsigned int
#define LINE P0//界说行线IO口,即74HC154操控端
#define shudu 12//字移动的速度
sbit DATA=P1^4;//74HC595数据端
sbit CLK=P1^5;//74HC595移位脉冲端
sbit CLKR=P1^6;//74HC595数据锁存端
uchar move;//移动几位变量
uchar line;//行变量
uint word;//字节变量
uchar ji,gai;//字节变量
uchar BUF[4];//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,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,0x10,0xFF,0x90,0x14,0x50,0x14,0x7C,0x7F,0x50,0x55,0x90,0x55,0x10,0x57,0xFE,
0x61,0x04,0x41,0x7E,0x41,0x44,0x7F,0x44,0x41,0x44,0x41,0x44,0x7F,0x7C,0x41,0x44,
0x00,0x78,0x3F,0x80,0x11,0x10,0x09,0x20,0x7F,0xFE,0x42,0x02,0x82,0x04,0x7F,0xF8,
0x04,0x00,0x07,0xF0,0x0A,0x20,0x09,0x40,0x10,0x80,0x11,0x60,0x22,0x1C,0x0C,0x08,
0x04,0x40,0x04,0x44,0xFF,0xFE,0x04,0x40,0x08,0x7C,0x09,0x44,0x7F,0xC4,0x08,0x7C,
0x0A,0x44,0x3F,0x44,0x22,0x7C,0x22,0x44,0x22,0x44,0x3E,0x44,0x22,0x94,0x01,0x08,
0x08,0x20,0x08,0x24,0xFF,0xFE,0x08,0x20,0x01,0x08,0x3F,0xFC,0x20,0x08,0x20,0x08,
0x3F,0xF8,0x20,0x08,0x20,0x00,0x20,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x80,0x00,
0x08,0x10,0x08,0x10,0x08,0x10,0x10,0x20,0x10,0x20,0x22,0x44,0x7E,0xFC,0x04,0x08,
0x08,0x10,0x10,0x20,0x20,0x40,0x7E,0xFC,0x00,0x00,0x00,0x04,0xFF,0xFE,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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,
0x08,0x10,0x08,0x10,0x08,0x10,0x10,0x20,0x10,0x20,0x22,0x44,0x7E,0xFC,0x04,0x08,
0x08,0x10,0x10,0x20,0x20,0x40,0x7E,0xFC,0x00,0x00,0x00,0x04,0xFF,0xFE,0x00,0x00,
0x08,0x20,0x08,0x24,0xFF,0xFE,0x08,0x20,0x01,0x08,0x3F,0xFC,0x20,0x08,0x20,0x08,
0x3F,0xF8,0x20,0x08,0x20,0x00,0x20,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x80,0x00,
0x04,0x40,0x04,0x44,0xFF,0xFE,0x04,0x40,0x08,0x7C,0x09,0x44,0x7F,0xC4,0x08,0x7C,
0x0A,0x44,0x3F,0x44,0x22,0x7C,0x22,0x44,0x22,0x44,0x3E,0x44,0x22,0x94,0x01,0x08,
0x00,0x78,0x3F,0x80,0x11,0x10,0x09,0x20,0x7F,0xFE,0x42,0x02,0x82,0x04,0x7F,0xF8,
0x04,0x00,0x07,0xF0,0x0A,0x20,0x09,0x40,0x10,0x80,0x11,0x60,0x22,0x1C,0x0C,0x08,
0x01,0x10,0xFF,0x90,0x14,0x50,0x14,0x7C,0x7F,0x50,0x55,0x90,0x55,0x10,0x57,0xFE,
0x61,0x04,0x41,0x7E,0x41,0x44,0x7F,0x44,0x41,0x44,0x41,0x44,0x7F,0x7C,0x41,0x44,
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,
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,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,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[]={
0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00,
0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00
};
/************************************************************/
/*************************左掩盖数组************************/
/************************************************************/
uchar code table3[]={
0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00,
0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00
};
/*****************************************/
/*****************延时子程序*************/
/***************************************/
void delay(uchar z)
{
uchar x,y;
for(x=2;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 jian()
{
while(word<128)//要显现多少字?
{
for(move=150;move>0;move–)//字连续显现的速度
{
ji=word;
for(line=0;line<16;line++)
{
song(~table[ji*2+1]);//先右半屏
song(~table[ji*2]);//再左半屏
ji++;//下一行
CLKR=1;//在74HC595处锁存起来
CLKR=0;
CLKR=1;
LINE=line;//打开列
delay(17);
}
}
word=ji;
}
}
/************************************************************/
/************************************************************/
/**************************上移显现***************************/
/************************************************************/
/************************************************************/
void shang()
{
while(word<128)
{
for(move=20;move>0;move–)
{
ji=word;//将变量存起来
for(line=0;line<16;line++)
{
song(~table[ji*2+1]);
song(~table[ji*2]);
ji++;
CLKR=1;//在74HC595处锁存起来
CLKR=0;
CLKR=1;
LINE=line;
delay(5);
}
}
word+=1;//数组数添加一行,构成上移
}
}
/************************************************************/
/************************************************************/
/**************************下移显现***************************/
/************************************************************/
/************************************************************/
void xia()
{
while(word>1)
{
for(move=20;move>0;move–)
{
ji=word;//给倒数第2个字方位地址码给ji变量
for(line=0;line<16;line++)
{
song(~table1[ji*2+1]);//发右半屏数 留意这是数组1的代码
song(~table1[ji*2]);//发左半屏数
ji++;
CLKR=1;//在74HC595处锁存起来
CLKR=0;
CLKR=1;
LINE=line;
delay(5);
}
}
word-=1;//数组数减1一行,构成下移
}
}