当前位置:编程学习 > C/C++ >>

怎么用C语言控制16*16的LED显示汉字数字,汉字比如“欢迎光临”,数字比如“520”; 谢谢高手指点迷津!

追问:字模我知道,就是具体怎么来实现?字模不是还有共阴,共阳什么的吗?根据你的电路给数据驱动led。这个我不懂,具体怎么驱动啊 ?我电路都没有啊,老板就给我一个单片机开发板。。
答案:踩个脚印,回去看看
======================================
汇编的代码给你,相关的注释也写了,设计自己弄一下吧

SER    EQU   P1.0 ; TPIC6B595 第3脚
OE     EQU   P1.1;TPIC6B595 第8脚
RCK    EQU   P1.2;TPIC6B595 第12脚
MR     EQU   P1.3;TPIC6B595 第9脚
SRCLK  EQU  P1.4;TPIC6B595 第13脚
ORG 0000H
LJMP MAIN
ORG 0100H
;**************************主程序**********************************
MAIN: MOV  SP,#70H
SETB  OE      
MOV 2BH,#00H
MOV 27H,#00H
START:           ;初始化寄存器RAM单元
MOV R0, #30H
MOV R1,#64H     ;30H~6FH单元清零
MOV A, #00H
ST: MOV  @R0,A
   INC R0
   DJNZ R1,ST
;2Dh------寻址偏址        ;整屏四个字一起显示
LOOP:MOV DPTR,#TAB;赋查表初值
MOV R3,#56
PLAY: MOV 2DH,#00H
 MOV 2FH,#10H
GG: LCALL LINE16;扫描显示一次
MOV 2DH,#00H
DJNZ 2FH,GG
MOV A,DPL
CLR C
ADD A, #16
MOV DPL ,A
MOV A, DPH
ADDC A ,#00H
MOV DPH, A
DJNZ R3,PLAY
SJMP START
LINE16: MOV 2BH,#16;扫16行,2BH放后还剩几行
FF: LCALL LINE1;扫描显示一行子程序
DJNZ 2BH,FF;扫描行直到16行扫完再转
RET
LINE1:LCALL MSTR;将显示的内容移入内存单元
      LCALL SEND;发送串口子程序
      LCALL XH;选通行子程序
      RET
MSTR:   ;显示内容移入内存单元
      MOV R0,#30H
      MOV R4,#9
      MOV A,2DH;
BB:   MOVC  A,@A+DPTR
      MOV @R0,A
      INC R0
      MOV A,2DH
      ADD A,#16;加16移到下一行
      MOV 2DH,A
      DJNZ R4,BB
      MOV A,2DH
      SUBB A,#143
      MOV 2DH,A
      RET
;$$$$$$$$$$$$$$$$$$$$$$$$$$$发送数据到串口子程序$$$$$$$$$$$$$$$$$$$$$$$$$
SEND:MOV R0,#30H
     MOV R5,#8  ;一行有8个字节,如每次显示字数不同要作相应改动
     SETB OE
     SETB MR
     CLR SRCLK
     CLR RCK
     SETB P1.6
     SETB P1.7

LQ:  CLR C
     MOV R2,#8
     MOV A,@R0
     ;    CPL A ;TPIC6B595应该不用这一步
     LCALL DD1;调用显示一个字节的子程序
     INC R0;指向下一个显示单元
     DJNZ R5,LQ
     RET
DD1: CLR  SRCLK;清串行CP端
     RLC A;
     MOV SER,C
     SETB SRCLK ;触发串行CP端
     DJNZ R2,DD1;每个字节移8次够了向下执行
     RET
;选通行子程序
XH: CLR RCK ;将输出CP变成低电平为上升沿做准备
    NOP
    SETB RCK
    CLR P1.6
    ;CLR P1.7
    MOV A,27H
    MOV P0,A
    CLR    OE
LCALL DE25MS
INC  A
    SETB   OE
    SETB  P1.6
MOV A,27H   
ANL A,#0F0H
    SWAP A
    ADD A,#01H
    SWAP A
    MOV 27H,A
CLR    MR       
SETB   MR        
RET
DE25MS:    MOV  R5,#09H
 DEL2:      MOV  R6,#0FH
 DEL3:      MOV  R7,#01H
                DJNZ  R7,$
                DJNZ  R6,DEL3
                DJNZ  R5,DEL2
                RET
TAB:
字库
END

两点说明:
1. 上述程序可以整屏四个字一起显示,要是要显示你说的那么些字,还得作半屏控制,实现汉字滚动,太麻烦,一时半会儿出不来。

2. 
TAB:
字库
END
上面的字库根据你要显示的字,自己弄一下吧,给你个例子:
显示“欢迎光临”的话,字库为:
TAB:          ;欢
              DB   00H,20H,3CH,10H
              DB   44H,08H,84H,04H
              DB   04H,03H,04H,03H
              DB   84H,04H,44H,08H
              DB   3CH,10H,00H,20H
              DB   00H,00H,07H,20H
              DB   04H,10H,0F4H,0FH
              DB   04H,10H,1CH,20H  

              ;迎
              DB   00H,00H,49H,20H
              DB   6AH,10H,0DCH,0FH
              DB   08H,10H,00H,20H
              DB   0FEH,27H,02H,22H
              DB   02H,21H,81H,20H
              DB   00H,20H,02H,20H
              DB   0FEH,2FH,02H,22H
              DB   02H,22H,0FEH,21H

              ;光
              DB   00H,00H,00H,20H 
              DB   22H,20H,24H,20H
              DB   28H,10H,30H,08H
              DB   0E0H,07H,3FH,00H
              DB   20H,00H,0F0H,3FH
              DB   28H,20H,24H,20H
              DB   22H,20H,20H,20H
              DB   00H,38H,00H,00H

              ;临
              DB   00H,00H,0F0H,03H
              DB   00H,00H,00H,00H
              DB   0FFH,3FH,00H,00H
              DB   40H,00H,20H,3FH
              DB   10H,21H,0FH,21H
              DB   14H,21H,24H,3FH
              DB   44H,21H,04H,21H
              DB   04H,21H,04H,3FH
              DB   00H,00H,00H,00H

              END                       ;程序结束
其他:{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},/*"欢",0*/

{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},/*"迎",1*/

{0x00,0x00,0x40,0x80,0x42,0x40,0x44,0x20,0x5C,0x18,0xC8,0x07,0x40,0x00,0x7F,0x00},
{0x40,0x00,0xC0,0x3F,0x50,0x40,0x4E,0x40,0x44,0x40,0x60,0x40,0x40,0x78,0x00,0x00},/*"光",2*/

{0x00,0x00,0xF8,0x1F,0x00,0x00,0x00,0x00,0xFE,0x7F,0x40,0x00,0x30,0x00,0x8F,0x7F},
{0x0A,0x21,0x08,0x21,0x18,0x3F,0x68,0x21,0x08,0x21,0x88,0x7F,0x08,0x01,0x00,0x00},/*"临",3*/ 字模生成软件生成代码,根据你的电路给数据驱动led。

上一个:我的这个c语言小程序有什么问题?
下一个:11)下列说法中错误的是( ) A.在不同的函数中可以使用相同名字的变量 B.函数中的形参是局部变量 C.在一个

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,