本文包含原理图、PCB、源代码、封装库、中英文PDF等资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
我用HC138+4953作行驱,HC595作列驱,用附件的程序实现了12个字,分3次显示,每次显示4个字,循环显示.
初学者可以下载同共学习下.
另:
我想改为左移滚动显示,请问要修改程序什么地方,希望高手帮个忙指点下,或者说帮忙修改下加个注释更佳.
程序如下:
#include<reg52.h>
#define ROW_address P2 //138 A B C D数据口
sbit R1=P1^0; //串行数据输入引脚(HC595-14脚)
sbit SK=P1^1; //输入移位时钟脉冲,在上升沿移位寄存器 (HC595-11脚)
sbit LT=P1^2; //上升沿时将数据输出到并行端口(HC595-12脚)
sbit EN=P1^3; //使能端,高电平禁止输出(HC595-13脚)
unsigned char code GB_16[] =
{
0x08,0x00,0x10,0x40,0x06,0x08,0x10,0x20,0x0C,0x00,0x18,0x40,0x78,0x88,0x10,0x20,
0x19,0xFC,0x27,0xFE,0x08,0x48,0x10,0x20,0x10,0x04,0x50,0x40,0x08,0x48,0xFD,0xFE,
0x22,0x04,0x9B,0xFC,0xFE,0x08,0x10,0x20,0x43,0x04,0x32,0x94,0x18,0x88,0x14,0x20,
0xFE,0x04,0x22,0x94,0x1C,0x48,0x19,0xFC,0x04,0x04,0x63,0xFC,0x2A,0x48,0x31,0x08,
0x08,0x04,0xA0,0x00,0x28,0x0E,0xD0,0x88,0x0A,0x04,0x2F,0xFE,0x48,0x78,0x10,0x90,
0x11,0x04,0x20,0x00,0x8B,0x88,0x10,0x60,0x7F,0x84,0x25,0x44,0x08,0x08,0x10,0x60,
0x21,0x04,0x25,0x22,0x08,0x08,0x10,0x90,0x00,0x28,0x25,0x0A,0x08,0x08,0x11,0x0E,
0x00,0x10,0x28,0xF8,0x08,0x08,0x56,0x04,0x00,0x00,0x20,0x00,0x08,0x08,0x20,0x00,
0x01,0x00,0x11,0x08,0x20,0x90,0x00,0x04,0x01,0x00,0x10,0x90,0x20,0x90,0x7F,0x84,
0x01,0x00,0x10,0xA0,0x27,0xFC,0x12,0x24,0x3F,0xF8,0xFB,0xFC,0x20,0x90,0x12,0x24,
0x21,0x08,0x10,0x44,0xFB,0xF8,0xFF,0xE4,0x21,0x08,0x38,0x44,0x22,0x08,0x12,0x24,
0x3F,0xF8,0x37,0xFC,0x73,0xF8,0x12,0x24,0x21,0x08,0x52,0x40,0x6A,0x08,0x22,0x24,
0x21,0x08,0x52,0x40,0xA3,0xF8,0x22,0x04,0x21,0x08,0x93,0xFE,0xA0,0x40,0x41,0x14,
0x3F,0xF8,0x10,0xC2,0x27,0xFE,0x01,0x08,0x21,0x08,0x11,0x42,0x20,0x40,0x3F,0xFC,
0x01,0x02,0x12,0x4A,0x20,0xA0,0x01,0x00,0x01,0x02,0x14,0x44,0x20,0x98,0x01,0x00,
0x00,0xFE,0x10,0x40,0x21,0x0E,0xFF,0xFE,0x00,0x00,0x10,0x40,0x26,0x04,0x00,0x00,
0x20,0x00,0x20,0x40,0x01,0x00,0x02,0x00,0x3F,0x00,0x30,0x40,0x01,0x00,0x02,0x00,
0x48,0x7C,0x24,0x4C,0x01,0x00,0x7F,0xFC,0x08,0x44,0x42,0x70,0x01,0x00,0x04,0x00,
0xFF,0x44,0xFF,0x44,0x09,0x40,0x04,0x80,0x0C,0x44,0x42,0x46,0x0D,0x20,0x08,0x80,
0x0A,0x7C,0x00,0x7C,0x19,0x10,0x10,0x80,0x11,0x00,0x7E,0x00,0x11,0x18,0x3F,0xFC,
0x6F,0xF0,0x42,0x40,0x21,0x0C,0x00,0x80,0x08,0x10,0x7E,0x4C,0x41,0x06,0x00,0x80,
0x08,0x10,0x42,0x70,0x81,0x04,0xFF,0xFE,0x0F,0xF0,0x7E,0x40,0x01,0x00,0x00,0x80,
0x08,0x10,0x42,0x44,0x01,0x00,0x00,0x80,0x08,0x10,0x42,0x46,0x01,0x00,0x00,0x80,
0x0F,0xF0,0x4A,0x3C,0x05,0x00,0x00,0x80,0x08,0x10,0x44,0x00,0x02,0x00,0x00,0x80,
};
unsigned int x=0;
unsigned long cnt=0;
unsigned int Row=0;
void delay(unsigned int i)//延时函数
{
unsigned int j,k;
for(i;i>0;i--)
for(j=10;j>0;j--)
for(k=200;k>0;k--);
}
void display(unsigned int C_num)
{
unsigned char k,n,num,ff;
for(k=0;k<2*C_num;k++)
{
num=GB_16[8*Row+k+128*x];
for(n=0;n<8;n++)
{
SK=0;
R1=~num&0x80;
SK=1;
num<<=1;
}
}
EN=1;
LT=1;
LT=0;
ROW_address=Row;
EN=0;
}
void time0() interrupt 1
{
TH0=0xf8;
TL0=0x09;
Row++;
if(Row==16)
Row=0;
display(4);
cnt++;
}
void init()
{
TMOD=0x01;
TH0=0xf8;
TL0=0xc9;
ET0=1;
TR0=1;
EA=1;
}
void main()
{
init();
while(1)
{
if(cnt==1000)
{
cnt=0;
x++;
if(x==3)
x=0;
delay(10);
}
}
} |