单片机开发板8*8点阵LED数码管如何显示一句话

2024-11-08 20:05:33
推荐回答(5个)
回答(1):

#include
typedef unsigned char uint8;
typedef unsigned int uint16;
typedef unsigned long uint32;

code uint8 graph[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xC3,0xE7,0xE7,0xE7,0xE7,0xC3,0xFF,
0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,0xE7,
0xFF,0x99,0x99,0x99,0x99,0x81,0xC3,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
};
sbit ENLED = P1^4;
sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;

uint8 i= 0,counter = 0;

void timer1_init()
{
TMOD |= 0x10;
TMOD &= 0xdf;
TH1 = 0xFC;
TL1 = 0x67;
TR1 = 1;
}
void int_init()
{
ET1 = 1;
EA = 1;
}
void refresh_led()
{
static uint8 j = 0;
switch(j)
{
case 0: ADDR0 = 0;ADDR1 = 0;ADDR2 = 0;break;
case 1: ADDR0 = 1;ADDR1 = 0;ADDR2 = 0;break;
case 2: ADDR0 = 0;ADDR1 = 1;ADDR2 = 0;break;
case 3: ADDR0 = 1;ADDR1 = 1;ADDR2 = 0;break;
case 4: ADDR0 = 0;ADDR1 = 0;ADDR2 = 1;break;
case 5: ADDR0 = 1;ADDR1 = 0;ADDR2 = 1;break;
case 6: ADDR0 = 0;ADDR1 = 1;ADDR2 = 1;break;
case 7: ADDR0 = 1;ADDR1 = 1;ADDR2 = 1;break;
default: break;
}
P0 = graph[i + j];
if(7 == j++) j = 0;

}

main()
{
ENLED = 0; ADDR3 = 0;
timer1_init();
int_init();
while(1);

}
void interrupt_timer1() interrupt 3
{
TH1 = 0xFC;
TL1 = 0x67;
counter++;
if(counter == 200)
{
counter = 0;
i++;
if(i>=32){i=0;}
}
refresh_led();

}这程序显示字母I FC U 8*8太小了 改下就可以了

回答(2):

#include
typedef unsigned char uint8;
typedef unsigned int uint16;
typedef unsigned long uint32;

code uint8 graph[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xC3,0xE7,0xE7,0xE7,0xE7,0xC3,0xFF,
0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,0xE7,
0xFF,0x99,0x99,0x99,0x99,0x81,0xC3,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
};
sbit ENLED = P1^4;
sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;

uint8 i= 0,counter = 0;

void timer1_init()
{
TMOD |= 0x10;
TMOD &= 0xdf;
TH1 = 0xFC;
TL1 = 0x67;
TR1 = 1;
}
void int_init()
{
ET1 = 1;
EA = 1;
}
void refresh_led()
{
static uint8 j = 0;
switch(j)
{
case 0: ADDR0 = 0;ADDR1 = 0;ADDR2 = 0;break;
case 1: ADDR0 = 1;ADDR1 = 0;ADDR2 = 0;break;
case 2: ADDR0 = 0;ADDR1 = 1;ADDR2 = 0;break;
case 3: ADDR0 = 1;ADDR1 = 1;ADDR2 = 0;break;
case 4: ADDR0 = 0;ADDR1 = 0;ADDR2 = 1;break;
case 5: ADDR0 = 1;ADDR1 = 0;ADDR2 = 1;break;
case 6: ADDR0 = 0;ADDR1 = 1;ADDR2 = 1;break;
case 7: ADDR0 = 1;ADDR1 = 1;ADDR2 = 1;break;
default: break;
}
P0 = graph[i + j];
if(7 == j++) j = 0;

}

main()
{
ENLED = 0; ADDR3 = 0;
timer1_init();
int_init();
while(1);

}
void interrupt_timer1() interrupt 3
{
TH1 = 0xFC;
TL1 = 0x67;
counter++;
if(counter == 200)
{
counter = 0;
i++;
if(i>=32){i=0;}
}
refresh_led();

}这程序显示字母I FC U 8*8太小了 改下就可以了

回答(3):

8*8只能显示字母或数字 不能显示汉字 除非是16*16的 如果是单块点阵的花只能动态显示 刷屏似的显示内容 要想完整显示一句话需要拼接点阵 否则不可以

回答(4):

整块屏幕共有多少点阵?如果只能显示一个字,那你就循环显示啊,我建议用那些液晶显示屏吧,就十几块,而且字库都在里面了,只要给命令调用就好。

回答(5):

就让它一个接一个显示呗