本人要做16X64LED显示汉字,LED接口如下图,显示时出了问题,只在通电的一瞬间LED才亮一下,求大神们解答。。。。。。 我采用的是普中科技的单片机,芯片是89C52RC,程序如下,如大神发现我程序有错麻烦指出,或者可以根据我提供的LED接口,单片机,芯片帮我重新写一个程序,小弟感激不尽。。。。
#include<reg51.h>
#include<stdio.h>
#define uchar unsigned char
#define uint unsigned int
#define ul unsigned long
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, //0 //右一上的起点
0x00,0x1f,0x11,0x11,0x1f,0x11,0x11,0x1f, //A
0x00,0xf0,0x10,0x10,0x10,0xf0,0x10,0x10, //B
0x20,0x12,0x12,0x12,0x12,0xff,0x12,0x12, //C
0x20,0x20,0x20,0x20,0x20,0xff,0x20,0x20, //D
0x00,0xfc,0x04,0x08,0x10,0x20,0x20,0xfe, //E
0x10,0x10,0x10,0x10,0xfc,0x24,0x24,0x25, //F
0x91,0x11,0x12,0x12,0x14,0x10,0x10,0x10, //G
0x28,0x24,0x24,0x22,0x22,0x20,0xa0,0x40, //H
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0 //右八上的终点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右七上的终点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
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, //0 //右一下的起点
0x02,0x0c,0x34,0xc4,0x04,0x08,0x08,0x10, //A
0x80,0x60,0x58,0x46,0x40,0x40,0x40,0x40, //B
0x12,0x12,0x13,0x10,0x10,0x10,0x1f,0x00, //C
0x20,0x20,0xe0,0x00,0x00,0x00,0xff,0x00, //D
0x24,0x48,0x28,0x10,0x28,0x44,0x84,0x00,
0x10,0xa0,0x20,0x20,0x20,0x20,0x20,0x20,
0x91,0x11,0x12,0x12,0x14,0x10,0x10,0x10,
0x28,0x24,0x24,0x22,0x22,0x20,0xa0,0x40,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0 //右八下的终点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
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 table3[]=
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右八上的起点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右七上的起点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右六上的起点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右五上的起点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右四上的起点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右三上的起点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右二上的起点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0 //右一上的起点
0x00,0x1f,0x11,0x11,0x1f,0x11,0x11,0x1f, //A
0x00,0xf0,0x10,0x10,0x10,0xf0,0x10,0x10, //B
0x20,0x12,0x12,0x12,0x12,0xff,0x12,0x12, //C
0x20,0x20,0x20,0x20,0x20,0xff,0x20,0x20, //D
0x00,0xfc,0x04,0x08,0x10,0x20,0x20,0xfe, //E
0x10,0x10,0x10,0x10,0xfc,0x24,0x24,0x25, //F
0x91,0x11,0x12,0x12,0x14,0x10,0x10,0x10, //G
0x28,0x24,0x24,0x22,0x22,0x20,0xa0,0x40, //H
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0 //右八上的终点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右七上的终点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
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 table4[]=
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右八上的起点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右七上的起点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右六上的起点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右五上的起点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右四上的起点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右三上的起点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右二上的起点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0 //右一上的起点
0x00,0x1f,0x11,0x11,0x1f,0x11,0x11,0x1f, //A
0x00,0xf0,0x10,0x10,0x10,0xf0,0x10,0x10, //B
0x20,0x12,0x12,0x12,0x12,0xff,0x12,0x12, //C
0x20,0x20,0x20,0x20,0x20,0xff,0x20,0x20, //D
0x00,0xfc,0x04,0x08,0x10,0x20,0x20,0xfe, //E
0x10,0x10,0x10,0x10,0xfc,0x24,0x24,0x25, //F
0x91,0x11,0x12,0x12,0x14,0x10,0x10,0x10, //G
0x28,0x24,0x24,0x22,0x22,0x20,0xa0,0x40, //H
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //0 //右八上的终点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //右七上的终点
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
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 i,temp,num,j,k;
sbit SH_CK=P1^0;
sbit ST_CK=P1^2;
sbit SD=P1^1;
sbit EN=P1^3;
sbit BUT1=P3^2;
sbit BUT2=P3^3;
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=90;y>0;y--);
}
void init()
{
TMOD=0x01;//方式1,16位模式,不会自动清零。
TH0=(65536-50000)/2048;
TL0=(65536-50000)%2048;
TR0=1;
EA=1;
ET0=1;
EX0=1;
EX1=1;
IT0=1;
IT1=1;
num=0;
j=0;
}
void d_in(unsigned char Data){ //列扫描
uchar i;
for(i=0;i<8;i++){
SH_CK = 0;
SD = Data&0x80;
Data<<=1;
SH_CK = 1;
}
}
void d_out(){
ST_CK = 0;
ST_CK = 1;
}
void data1();
void data2();
void main(void)
{
init();
k = 0;
while(1)
{
if(k == 0)
data1();
if(k == 1)
data2();
}
}
void timer0() interrupt 1
{
num++;
TH0=(65536-50000)/2048;
TL0=(65536-50000)%2048;
if(num==10)
{
num=0;
j = j+8;
if(j==128) //决定扫描的终点
j=0;
}
}
void ext0() interrupt 0
{
k++;
if(k == 2)
k = 0;
}
void ext1() interrupt 3
{
k--;
if(k == -1)
k = 1;
}
void data1(){
temp=0x00;
for(i=0;i<8;i++) //扫描第1行之第8行
{
P2=temp;
EN = 1;
d_in(table1[i+j]);
d_in(table1[i+j+8]);
d_in(table1[i+j+16]);
d_in(table1[i+j+24]);
d_in(table1[i+j+32]);
d_in(table1[i+j+40]);
d_in(table1[i+j+48]);
d_in(table1[i+j+56]);
d_out();
EN = 0;
delay(3);
temp=temp+0x01;
if(k == 1)
break;
}
for(i=0;i<8;i++) //扫描第9行之第16行
{
P2=temp;
EN = 1;
d_in(table2[i+j]);
d_in(table2[i+j+8]);
d_in(table2[i+j+16]);
d_in(table2[i+j+24]);
d_in(table2[i+j+32]);
d_in(table2[i+j+40]);
d_in(table2[i+j+48]);
d_in(table2[i+j+56]);
d_out();
EN = 0;
delay(3);
temp=temp+0x01;
if(k == 1)
break;
}
}
void data2(){
temp=0x00;
for(i=0;i<8;i++) //扫描第1行之第8行
{
P2=temp;
EN = 1;
d_in(table3[i+j]);
d_in(table3[i+j+8]);
d_in(table3[i+j+16]);
d_in(table3[i+j+24]);
d_in(table3[i+j+32]);
d_in(table3[i+j+40]);
d_in(table3[i+j+48]);
d_in(table3[i+j+56]);
d_out();
EN = 0;
delay(3);
temp=temp+0x01;
if(k == 2)
break;
}
for(i=0;i<8;i++) //扫描第9行之第16行
{
P2=temp;
EN = 1;
d_in(table4[i+j]);
d_in(table4[i+j+8]);
d_in(table4[i+j+16]);
d_in(table4[i+j+24]);
d_in(table4[i+j+32]);
d_in(table4[i+j+40]);
d_in(table4[i+j+48]);
d_in(table4[i+j+56]);
d_out();
EN = 0;
delay(3);
temp=temp+0x01;
if(k == 2)
break;
}
}
此帖出自
小平头技术问答
非常感谢
非常感谢。。。。。。。。。。。。。
店家没发给你吗?买的时候就要搞清楚这些再下单,如果自己不是很清楚从何下手,就要好好考虑能不能自己研究出来
一周热门 更多>