打印

16x64点阵怎么显示一个汉字

[复制链接]
3096|10
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zzjyyw|  楼主 | 2013-6-8 11:21 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
我做个点阵16x64的,51单片机,595驱动行,154驱动列,行为1列为0时点亮,现在是只能四位同时显示,我想在在特定的位置显示一个汉字,应该怎么写程序

源程序为
#include <reg52.h>
#include "74hc595.h"

#define uchar unsigned char
#define uint unsigned int





uchar tab[]={0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff};

uchar code discode[]={
0x10,0x04,0x61,0xFC,0x86,0x03,0x60,0x00,0x08,0x42,0x08,0x81,0xFF,0x7F,0x88,0x40,
0x08,0x30,0xFE,0x0F,0x22,0x00,0x22,0x00,0xE2,0xFF,0x22,0x00,0x22,0x00,0x00,0x00,/*"浙",0*/

0x10,0x04,0x60,0x04,0x01,0x7E,0xC6,0x01,0x30,0x20,0x00,0x20,0x04,0x20,0x04,0x20,
0x04,0x20,0xFC,0x3F,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x00,0x20,0x00,0x00,/*"江",1*/

0x00,0x82,0x02,0x4A,0x02,0x2A,0xE2,0x1E,0xAA,0x4B,0xAA,0x8A,0xAA,0x7A,0xAF,0x02,
0xAA,0x02,0xAA,0x7B,0xAA,0x4A,0xE2,0x4A,0x02,0x7A,0x02,0x02,0x00,0x02,0x00,0x00,/*"嘉",2*/

0x00,0x40,0x82,0x20,0x8C,0x10,0xB8,0x18,0x90,0x0E,0x82,0x04,0x8C,0x00,0xB8,0x00,
0x90,0x00,0x80,0x02,0xC0,0x04,0xB0,0x18,0x9E,0x70,0x84,0x20,0x80,0x00,0x00,0x00,/*"兴",3*/

0x14,0x20,0x24,0x10,0x44,0x4C,0x84,0x43,0x64,0x43,0x1C,0x2C,0x20,0x20,0x18,0x10,
0x0F,0x0C,0xE8,0x03,0x08,0x06,0x08,0x18,0x28,0x30,0x18,0x60,0x08,0x20,0x00,0x00,/*"欢",4*/

0x40,0x40,0x41,0x20,0xCE,0x1F,0x04,0x20,0x00,0x40,0xFC,0x47,0x04,0x42,0x02,0x41,
0x02,0x40,0xFC,0x5F,0x04,0x40,0x04,0x42,0x04,0x44,0xFC,0x43,0x00,0x40,0x00,0x00,/*"迎",5*/

0x80,0x00,0x40,0x20,0x30,0x38,0xFC,0x03,0x03,0x38,0x90,0x40,0x68,0x40,0x06,0x49,
0x04,0x52,0xF4,0x41,0x04,0x40,0x24,0x70,0x44,0x00,0x8C,0x09,0x04,0x30,0x00,0x00,/*"您",6*/

0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x5F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"!",7*/



                         };

uchar code shuzi[]={
// 0(0) 1(1) 2(2) 3(3) 4(4) 5(5) 6(6) 7(7) 8(8) 9(9)

0x00,0x00,0xE0,0x0F,0x10,0x10,0x08,0x20,0x08,0x20,0x10,0x10,0xE0,0x0F,0x00,0x00,/*"0",0*/
0x00,0x00,0x10,0x20,0x10,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,/*"1",1*/
0x00,0x00,0x70,0x30,0x08,0x28,0x08,0x24,0x08,0x22,0x88,0x21,0x70,0x30,0x00,0x00,/*"2",2*/
0x00,0x00,0x30,0x18,0x08,0x20,0x88,0x20,0x88,0x20,0x48,0x11,0x30,0x0E,0x00,0x00,/*"3",3*/
0x00,0x00,0x00,0x07,0xC0,0x04,0x20,0x24,0x10,0x24,0xF8,0x3F,0x00,0x24,0x00,0x00,/*"4",4*/
0x00,0x00,0xF8,0x19,0x08,0x21,0x88,0x20,0x88,0x20,0x08,0x11,0x08,0x0E,0x00,0x00,/*"5",5*/
0x00,0x00,0xE0,0x0F,0x10,0x11,0x88,0x20,0x88,0x20,0x18,0x11,0x00,0x0E,0x00,0x00,/*"6",6*/
0x00,0x00,0x38,0x00,0x08,0x00,0x08,0x3F,0xC8,0x00,0x38,0x00,0x08,0x00,0x00,0x00,/*"7",7*/
0x00,0x00,0x70,0x1C,0x88,0x22,0x08,0x21,0x08,0x21,0x88,0x22,0x70,0x1C,0x00,0x00,/*"8",8*/
0x00,0x00,0xE0,0x00,0x10,0x31,0x08,0x22,0x08,0x22,0x10,0x11,0xE0,0x0F,0x00,0x00,/*"9",9*/
};

void delay_ms(uint xms)
{
        uint i,j;
        for(i=xms;i>0;i--)
                for(j=110;j>0;j--);
}


void main()
{
        uchar i,k;
        int j;
        while(1)
        {
       
                for(i=0;i<16;i++)
                {       
                       
                        for(j=3;j>=0;j--)                                                             //显示“浙江嘉兴”

                        {
                                write_74HC595(discode[j*32+2*i+1]);          
                                write_74HC595(discode[j*32+2*i]);       

                        }

                        P3=tab[i];
                        out_74HC595();       
                       
                }       

        }
}


#ifndef __74HC595_H__
#define __74HC595_H__

#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int



sbit DS=P1^0;                //串行数据输入端
sbit SH_CP=P1^1;        //移位寄存器时钟
sbit ST_CP=P1^2;        //存储寄存器时钟


/*---------------------串行输入,并行输出-------------------------*/
void write_74HC595(uchar dat)
{
/*--------------------串行输入------------------------*/
        uchar i;
        for(i=0;i<8;i++)
        {
                SH_CP=0;               
                DS=dat&0x80;
                SH_CP=1;                        //移位脉冲上升沿
                dat=dat<<1;
        }

}
/*--------------------并行输出------------------------*/
void out_74HC595()
{
       
       
        ST_CP=0;
        ST_CP=1;                                //存储脉冲上升沿
        ST_CP=0;
}
#endif

4.jpg (62.59 KB )

4.jpg

3.jpg (61.61 KB )

3.jpg

2.jpg (74.91 KB )

2.jpg

1.jpg (77.06 KB )

1.jpg

相关帖子

沙发
hwk612167| | 2013-6-8 16:51 | 只看该作者
特定的位置? 随便哪一列?Or ?

使用特权

评论回复
板凳
huangxz| | 2013-6-8 17:04 | 只看该作者
只要有足够的分辨率,已经有字模,你可以自己控制哪个LED点亮啊

使用特权

评论回复
地板
zzjyyw|  楼主 | 2013-6-9 10:33 | 只看该作者
比如说我想在第一个16x16点阵处显示浙,后三个不显示,或者第一个、第三个显示,其余两个不显示

使用特权

评论回复
5
zzjyyw|  楼主 | 2013-6-9 10:35 | 只看该作者
huangxz 发表于 2013-6-8 17:04
只要有足够的分辨率,已经有字模,你可以自己控制哪个LED点亮啊

足够分辨率是什么意思

使用特权

评论回复
6
zzjyyw|  楼主 | 2013-6-9 10:36 | 只看该作者
hwk612167 发表于 2013-6-8 16:51
特定的位置? 随便哪一列?Or ?

比如说我想在第一个16x16点阵处显示浙,后三个不显示,或者第一个、第三个显示,其余两个不显示

使用特权

评论回复
7
老鱼探戈| | 2013-6-9 11:08 | 只看该作者
zzjyyw 发表于 2013-6-9 10:33
比如说我想在第一个16x16点阵处显示浙,后三个不显示,或者第一个、第三个显示,其余两个不显示 ...

不显示,灭掉就行了。

使用特权

评论回复
8
zzjyyw|  楼主 | 2013-6-9 11:45 | 只看该作者
明白了,

使用特权

评论回复
9
zzjyyw|  楼主 | 2013-6-9 11:46 | 只看该作者
老鱼探戈 发表于 2013-6-9 11:08
不显示,灭掉就行了。

明白啦

使用特权

评论回复
10
zzjyyw|  楼主 | 2013-6-9 13:47 | 只看该作者
还是16x64的点阵,我写的显示数字的程序,sz_leftdisplay(1,2,3,4)显示的是1 2 3 4 ,而sz_rightdisplay(1,2,3,4)显示的是2 3 4 5,求助

#include <reg52.h>
#include "74hc595.h"

#define uchar unsigned char
#define uint unsigned int


uchar code tab[]={0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff};

uchar code discode[]={
0x10,0x04,0x61,0xFC,0x86,0x03,0x60,0x00,0x08,0x42,0x08,0x81,0xFF,0x7F,0x88,0x40,
0x08,0x30,0xFE,0x0F,0x22,0x00,0x22,0x00,0xE2,0xFF,0x22,0x00,0x22,0x00,0x00,0x00,/*"浙",0*/

0x10,0x04,0x60,0x04,0x01,0x7E,0xC6,0x01,0x30,0x20,0x00,0x20,0x04,0x20,0x04,0x20,
0x04,0x20,0xFC,0x3F,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x00,0x20,0x00,0x00,/*"江",1*/

0x00,0x82,0x02,0x4A,0x02,0x2A,0xE2,0x1E,0xAA,0x4B,0xAA,0x8A,0xAA,0x7A,0xAF,0x02,
0xAA,0x02,0xAA,0x7B,0xAA,0x4A,0xE2,0x4A,0x02,0x7A,0x02,0x02,0x00,0x02,0x00,0x00,/*"嘉",2*/

0x00,0x40,0x82,0x20,0x8C,0x10,0xB8,0x18,0x90,0x0E,0x82,0x04,0x8C,0x00,0xB8,0x00,
0x90,0x00,0x80,0x02,0xC0,0x04,0xB0,0x18,0x9E,0x70,0x84,0x20,0x80,0x00,0x00,0x00,/*"兴",3*/

0x14,0x20,0x24,0x10,0x44,0x4C,0x84,0x43,0x64,0x43,0x1C,0x2C,0x20,0x20,0x18,0x10,
0x0F,0x0C,0xE8,0x03,0x08,0x06,0x08,0x18,0x28,0x30,0x18,0x60,0x08,0x20,0x00,0x00,/*"欢",4*/

0x40,0x40,0x41,0x20,0xCE,0x1F,0x04,0x20,0x00,0x40,0xFC,0x47,0x04,0x42,0x02,0x41,
0x02,0x40,0xFC,0x5F,0x04,0x40,0x04,0x42,0x04,0x44,0xFC,0x43,0x00,0x40,0x00,0x00,/*"迎",5*/

0x80,0x00,0x40,0x20,0x30,0x38,0xFC,0x03,0x03,0x38,0x90,0x40,0x68,0x40,0x06,0x49,
0x04,0x52,0xF4,0x41,0x04,0x40,0x24,0x70,0x44,0x00,0x8C,0x09,0x04,0x30,0x00,0x00,/*"您",6*/

0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x5F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"!",7*/

                         };

uchar code shuzi[]={
// 0(0) 1(1) 2(2) 3(3) 4(4) 5(5) 6(6) 7(7) 8(8) 9(9)

0x00,0x00,0xE0,0x0F,0x10,0x10,0x08,0x20,0x08,0x20,0x10,0x10,0xE0,0x0F,0x00,0x00,/*"0",0*/

0x00,0x00,0x10,0x20,0x10,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,/*"1",1*/

0x00,0x00,0x70,0x30,0x08,0x28,0x08,0x24,0x08,0x22,0x88,0x21,0x70,0x30,0x00,0x00,/*"2",2*/

0x00,0x00,0x30,0x18,0x08,0x20,0x88,0x20,0x88,0x20,0x48,0x11,0x30,0x0E,0x00,0x00,/*"3",3*/

0x00,0x00,0x00,0x07,0xC0,0x04,0x20,0x24,0x10,0x24,0xF8,0x3F,0x00,0x24,0x00,0x00,/*"4",4*/

0x00,0x00,0xF8,0x19,0x08,0x21,0x88,0x20,0x88,0x20,0x08,0x11,0x08,0x0E,0x00,0x00,/*"5",5*/

0x00,0x00,0xE0,0x0F,0x10,0x11,0x88,0x20,0x88,0x20,0x18,0x11,0x00,0x0E,0x00,0x00,/*"6",6*/

0x00,0x00,0x38,0x00,0x08,0x00,0x08,0x3F,0xC8,0x00,0x38,0x00,0x08,0x00,0x00,0x00,/*"7",7*/

0x00,0x00,0x70,0x1C,0x88,0x22,0x08,0x21,0x08,0x21,0x88,0x22,0x70,0x1C,0x00,0x00,/*"8",8*/

0x00,0x00,0xE0,0x00,0x10,0x31,0x08,0x22,0x08,0x22,0x10,0x11,0xE0,0x0F,0x00,0x00,/*"9",9*/

};

void delay_ms(uint xms)
{
        uint i,j;
        for(i=xms;i>0;i--)
                for(j=110;j>0;j--);
}



/*-------------------------四位显示-----------------------*/
void display4(uchar dat1,uchar dat2,uchar dat3,uchar dat4)
{
//        for(j=100;j>0;j--)          //显示时间
        uchar i;               
        for(i=0;i<16;i++)
        {
                write_74HC595(discode[i*2+dat4*32+1]);
                write_74HC595(discode[i*2+dat4*32]);

                write_74HC595(discode[i*2+dat3*32+1]);
                write_74HC595(discode[i*2+dat3*32]);

                write_74HC595(discode[i*2+dat2*32+1]);
                write_74HC595(discode[i*2+dat2*32]);

                write_74HC595(discode[i*2+dat1*32+1]);
                write_74HC595(discode[i*2+dat1*32]);

                P3=tab[i];
                out_74HC595();
        }
}
/*-------------------------四位数字左屏显示-----------------------*/
void sz_leftdisplay(uchar dat1,uchar dat2,uchar dat3,uchar dat4)
{
//        for(j=100;j>0;j--)          //显示时间
        uchar i;               
        for(i=0;i<8;i++)
        {
                write_74HC595(shuzi[i*2+dat4*16+1]);
                write_74HC595(shuzi[i*2+dat4*16]);

                write_74HC595(shuzi[i*2+dat3*16+1]);
                write_74HC595(shuzi[i*2+dat3*16]);

                write_74HC595(shuzi[i*2+dat2*16+1]);
                write_74HC595(shuzi[i*2+dat2*16]);

                write_74HC595(shuzi[i*2+dat1*16+1]);
                write_74HC595(shuzi[i*2+dat1*16]);

                P3=tab[i];
                out_74HC595();
        }
}
/*-------------------------四位数字右屏显示-----------------------*/
void sz_rightdisplay(uchar dat1,uchar dat2,uchar dat3,uchar dat4)
{
//        for(j=100;j>0;j--)          //显示时间
        uchar i;               
        for(i=8;i<16;i++)
        {
                write_74HC595(shuzi[i*2+dat4*16+1]);
                write_74HC595(shuzi[i*2+dat4*16]);

                write_74HC595(shuzi[i*2+dat3*16+1]);
                write_74HC595(shuzi[i*2+dat3*16]);

                write_74HC595(shuzi[i*2+dat2*16+1]);
                write_74HC595(shuzi[i*2+dat2*16]);

                write_74HC595(shuzi[i*2+dat1*16+1]);
                write_74HC595(shuzi[i*2+dat1*16]);

                P3=tab[i];
                out_74HC595();
        }
}


}
void main()
{
        uchar i,k;
        int j;
        while(1)
        {
                   for(j=100;j>0;j--)
                   sz_leftdisplay(1,2,3,4);
                   for(j=100;j>0;j--)
                   sz_rightdisplay(1,2,3,4);
        }
}






sz_leftdisplay()1,2,3,4.jpg (105.59 KB )

sz_leftdisplay()1,2,3,4.jpg

sz_rightdisplay(1,2,3,4).jpg (106.47 KB )

sz_rightdisplay(1,2,3,4).jpg

使用特权

评论回复
11
L2519885| | 2014-5-10 17:22 | 只看该作者
长见识了  很受用

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

13

帖子

1

粉丝