您现在的位置是:首页 > 电路图 > 电路图

点阵式LED简单图形显示技术

转载来源:电子技术应用-AET chinaaet.com 电子发烧友 elecfans.com2017-03-16

简介1.实验任务 在8X8点阵式LED显示“★”、“●”和心形图,通过按键来选择要显示的图形。 2.电路原理图 3.硬件系统连线 (1).把“单片机系统”区域中的P1端口用8芯排芯连接到“点阵

1.实验任务
在8X8点阵式LED显示“★”、“●”和心形图,通过按键来选择要显示的图形。
2.电路原理图

3.硬件系统连线
(1).把“单片机系统”区域中的P1端口用8芯排芯连接到“点阵模块”区域中的“DR1-DR8”端口上;
(2).把“单片机系统”区域中的P3端口用8芯排芯连接到“点阵模块”区域中的“DC1-DC8”端口上;
(3).把“单片机系统”区域中的P2.0/A8端子用导线连接到“独立式键盘”区域中的SP1端子上;
4.程序设计内容

 

(1).“★”在8X8LED点阵上显示图如下图所示

12H,14H,3CH,48H,3CH,14H,12H,00H
(2).  “●”在8X8LED点阵上显示图如下图所示

00H,00H,38H,44H,44H,44H,38H,00H
(3).心形图在8X8LED点阵上显示图如下图所示

30H,48H,44H,22H,44H,48H,30H,00H

5.汇编源程序
CNTA        EQU 30H
COUNT    EQU 31H
                   ORG 00H
                   LJMP START
                   ORG 0BH
                   LJMP T0X
                   ORG 30H
START:      MOV CNTA,#00H
                   MOV COUNT,#00H
                   MOV TMOD,#01H
                   MOV TH0,#(65536-4000) / 256
                   MOV TL0,#(65536-4000) MOD 256
                   SETB TR0
                   SETB ET0
                   SETB EA
WT:            JB P2.0,WT
                   MOV R6,#5
                   MOV R7,#248
D1:             DJNZ R7,$
                   DJNZ R6,D1
                   JB P2.0,WT
                   INC COUNT
                   MOV A,COUNT
                   CJNE A,#03H,NEXT
                   MOV COUNT,#00H
NEXT:       JNB P2.0,$
                   SJMP WT
T0X: NOP
                   MOV TH0,#(65536-4000) / 256
                   MOV TL0,#(65536-4000) MOD 256
                   MOV DPTR,#TAB
                   MOV A,CNTA
                   MOVC A,@A+DPTR
                   MOV P3,A
                   MOV DPTR,#GRAPH
                   MOV A,COUNT
                   MOV B,#8
                   MUL AB
                   ADD A,CNTA
                   MOVC A,@A+DPTR
                   MOV P1,A
                   INC CNTA
                   MOV A,CNTA
                   CJNE A,#8,NEX
                   MOV CNTA,#00H
NEX:         RETI
TAB:          DB 0FEH,0FDH,0FBH,0F7H,0EFH,0DFH,0BFH,07FH
GRAPH:    DB 12H,14H,3CH,48H,3CH,14H,12H,00H
                   DB 00H,00H,38H,44H,44H,44H,38H,00H
                   DB 30H,48H,44H,22H,44H,48H,30H,00H
                   END
6.C语言源程序
#include
unsigned char code tab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code graph[3][8]={{0x12,0x14,0x3c,0x48,0x3c,0x14,0x12,0x00},
                                {0x00,0x00,0x38,0x44,0x44,0x44,0x38,0x00},
                                {0x30,0x48,0x44,0x22,0x44,0x48,0x30,0x00}
                               };
unsigned char count;
unsigned char cnta;
void main(void)
{
  unsigned char i,j;
  TMOD=0x01;
  TH0=(65536-4000)/256;
  TL0=(65536-4000)%6;
  TR0=1;
  ET0=1;
  EA=1;
  while(1)
    {
      if(P2_0==0)
        {
          for(i=5;i>0;i--)
          for(j=248;j>0;j--);
          if(P2_0==0)
            {
              count++;
              if(count==3)
                {
                  count=0;
                }
              while(P2_0==0);
            }
        }
    }
}
void t0(void) interrupt 1 using 0
{
  TH0=(65536-4000)/256;
  TL0=(65536-4000)%6;
  P3=tab[cnta];
  P1=graph[count][cnta];
  cnta++;
  if(cnta==8)
    {
      cnta=0;
    }
}