点阵式LED的汉字显示,,c语言编程咋弄啊。。。谢谢各位啦

点阵式LED的汉字显示,,c语言编程咋弄啊。。。谢谢各位啦,第1张

我只弄过汇编的。

就一层循环,控制行,对于每一行,按照 显示——延时——全灭,然后处理下一行

具体结果就像这样。一边的端口按照1, 2, 4, 8, 16, 32, 64, 128, 1, 2, 4, 8, ……输出下去

另一边配合着输出每一行的信号,即可

记得更改行之前要把输出清零,不然整个led点阵一下子全亮起来了的样子

分类: 电脑/网络 >> 程序设计 >> 其他编程语言

问题描述:

这是给出的相关的材料,请教达人指点啊

我不知道如何动手,也不清楚代码要怎么写

希望高手给编写出来吧谢谢了

/ Chars are defined as 5 columns with each 8 bit, (5x8 font)

lowest 4 dots up to down 1,2,4,8 is higher nibble,

upper 4 dots up to down is lower nibble, for example:

| 123456

-+----------

|

1| xxx 1

2| x x 2

3| x x 4

4| x x __8 "A" is {0x7E,0x11,0x11,0x11,0x7E,0x00} (Last column blank)

5| xxxxx 1

6| x x 2

7| x x 4

8| 8

/

const byte prime_char_map[][6] = { {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ Block for test at startup / {0xFF,0xFF,0xFF,0xFF,0xFF,0x00}, \

/ 02 / {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ 03 / {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ 04 / {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ 05 / {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ 06 / {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ 07 / {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ 08 / {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ 09 / {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ 0A / {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ 0B / {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ 0C / {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ 0D / {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ 0E / {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ 0F / {0x00,0x00,0x00,0x00,0x00,0x00}, \

/ 10 / {0x00,0x7F,0x3E,0x1C,0x08,0x00}, \

/ 11 / {0x08,0x1C,0x3E,0x7F,0x00,0x00}, \

/ 12 / {0x44,0x66,0x77,0x66,0x44,0x00}, \

/ 13 / {0x11,0x33,0x77,0x33,0x11,0x00}, \

/ 14 / {0x48,0x77,0x49,0x41,0x42,0x00}, \

/ 15 / {0x30,0x48,0x45,0x40,0x20,0x00}, \

/ 16 / {0x00,0x00,0x7D,0x00,0x00,0x00}, \

/ 17 / {0x40,0xE0,0xE0,0x7F,0x06,0x00}, \

/ 18 / {0x24,0x42,0x81,0x42,0x24,0x00}, \

/ 19 / {0x0F,0xF0,0x00,0xF0,0x0F,0x00}, \

/ 1A / {0x20,0x40,0x20,0x10,0x08,0x00}, \

/ 1B / {0x7C,0x82,0x82,0x83,0x44,0x00}, \

/ 1C /

解析:

你的材料不全吧,看样子应该是prime_char_map[][6]第一维应该有256个元素的,你给出来的只是前面的一小部分,这里面很多都不是可显示的字符。下面是根据你的材料写的显示字符的程序:#include <stdioh>const byte prime_char_map[][6] = {{0x00,0x00,0x00,0x00,0x00,0x00}}; 这个地方你得把你的材料里的prime_char_map定义全都粘进来void Display(char c);void main(){Display('A');Display('b');}void Display(char c){int i, j;byte bit = 0x01;for (i = 0; i < 8; i++){for (j = 0; j < 6; j++){if (prime_char_map[c][j] & bit)printf("x");elseprintf(" ");}printf("\n");bit = 2;}}

这个程序可以循环显示0~9#include<reg51h>#include<intrinsh>#define uchar unsigned char#define uint unsigned intuchar code Table_of_Digits[]={0x00,0x3e,0x41,0x41,0x41,0x3e,0x00,0x00, //00x00,0x00,0x00,0x21,0x7f,0x01,0x00,0x00, //10x00,0x27,0x45,0x45,0x45,0x39,0x00,0x00, //20x00,0x22,0x49,0x49,0x49,0x36,0x00,0x00, //30x00,0x0c,0x14,0x24,0x7f,0x04,0x00,0x00, //40x00,0x72,0x51,0x51,0x51,0x4e,0x00,0x00, //50x00,0x3e,0x49,0x49,0x49,0x26,0x00,0x00, //60x00,0x40,0x40,0x40,0x4f,0x70,0x00,0x00, //70x00,0x36,0x49,0x49,0x49,0x36,0x00,0x00, //80x00,0x32,0x49,0x49,0x49,0x3e,0x00,0x00, //90xff,0x81,0x81,0x81,0x81,0x81,0x81,0xff};uchar code xdat[8]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};uchar code ydat[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};uchar i=0,j=0,t=0,Num_Index,key,xi,yi; sbit we1=P1^1;sbit we2=P1^3;//主程序void main(){//P1=0x80;Num_Index=0; //从0 开始显示TMOD=0x01; //T0 方式0TH0=(65536-2000)/256; //2ms 定时TL0=(65536-2000)%256;IE=0x82;key=0;xi=0;yi=0;EX0=1;IT0=1;TR0=1; //启动T0while(1);}//T0 中断函数void ext_int0() interrupt 0{ key++; key&=0x03;}void LED_Screen_Display() interrupt 1{TH0=(65536-2000)/256; //2ms 定时TL0=(65536-2000)%256;switch(key){case 0: P0=0xff; we1=1; P0=~Table_of_Digits[Num_Index8+i]; we1=0; P0=0xff; //输出位码和段码 we2=1; P0=xdat[i]; we2=0; if(++i==8) i=0; //每屏一个数字由8 个字节构成 if(++t==250) //每个数字刷新显示一段时间 { t=0; if(++Num_Index==10) Num_Index=0; //显示下一个数字 } break;case 1: we1=1; P0=~xdat[xi]; we1=0; we2=1; P0=ydat[yi]; we2=0; if(++t==250) //每个数字刷新显示一段时间 { t=0; yi++; if(yi>7){yi=0;xi++;} if(xi>7)xi=0; } break;case 2: we1=1; P0=0x00; we1=0; P0=0xff; //输出位码和段码 we2=1; P0=xdat[i]; we2=0; if(++t==250) //每个数字刷新显示一段时间 { if(++i==8) i=0; //每屏一个数字由8 个字节构成 t=0; } break;default: key=0; i=0; j=0; t=0; xi=0; yi=0; Num_Index=0; we1=1; P0=0xff; we1=0; we2=1; P1=0x80; we2=0; break;}}

以上就是关于点阵式LED的汉字显示,,c语言编程咋弄啊。。。谢谢各位啦全部的内容,包括:点阵式LED的汉字显示,,c语言编程咋弄啊。。。谢谢各位啦、C语言问题: 给出字符点阵,显示字符,请问应如何写程序代码、怎么写8×8led点阵屏显示数字0-9的程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/9297580.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-26
下一篇 2023-04-26

发表评论

登录后才能评论

评论列表(0条)

保存