点阵内部结构及外形如下,8X8点阵共由64个发光二极管组成,且每个发光二极管是放置在行线和列线的交叉点上,当对应的某一行置1电平,某一列置0电平,则相应的二极管就亮;如要将第一个点点亮,则Y0脚接高电平I0脚接低电平,则第一个点就亮了;如果要将第一行点亮,则第Y0脚要接高电平,而(I0、I1、I2、I3、I4、I5、I6、I7)这些引脚接低电平,那么第一行就会点亮;如要将第一列点亮,则第I0脚接低电平,而(Y0、Y1、Y2、Y3、Y4、Y5、Y6、Y7)接高电平,那么第一列就会点亮.
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit SD = P1^4; //串行数据输入
sbit ST_CK = P1^5; //存储寄存器时钟输入
sbit SH_CK = P1^6; //移位寄存器时钟输入
uchar code row[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
uchar code line[10][8]={{0x00,0x00,0x3E,0x41,0x41,0x3E,0x00,0x00},/*"0",0*/
{0x00,0x00,0x42,0x7F,0x40,0x00,0x00,0x00},/*"1",1*/
{0x00,0x00,0x62,0x51,0x49,0x46,0x00,0x00},/*"2",2*/
{0x00,0x00,0x22,0x49,0x49,0x36,0x00,0x00},/*"3",3*/
{0x00,0x00,0x38,0x26,0x7F,0x20,0x00,0x00},/*"4",4*/
{0x00,0x00,0x4F,0x49,0x49,0x31,0x00,0x00},/*"5",5*/
{0x00,0x00,0x3E,0x49,0x49,0x32,0x00,0x00},/*"6",6*/
{0x00,0x00,0x03,0x71,0x09,0x07,0x00,0x00},/*"7",7*/
{0x00,0x00,0x36,0x49,0x49,0x36,0x00,0x00},/*"8",8*/
{0x00,0x00,0x26,0x49,0x49,0x3E,0x00,0x00},/*"9",9*/};
void send_595(uchar Dat) //将8位数据存放在移位寄存器中
{
uchar i;
for(i = 0; i < 8; i++)
{
SH_CK = 0;
SD = Dat & 0x80;
Dat <<= 1;
SH_CK = 1;
}
}
void main()
{
uchar xl,xw;
uint j;
while(1)
{
for(xw=0;xw<10;xw++)
{
for(j=500;j>0;j--)
{
for(xl=0;xl<7;xl++)
{
send_595(row[xl]) ;
send_595(line[xw][xl]);
ST_CK = 0;
ST_CK = 1;//使移位寄存器中的数据进入数据寄存器
}
}
}
}
}