《LED点阵0到9显示.docx》由会员分享,可在线阅读,更多相关《LED点阵0到9显示.docx(10页珍藏版)》请在金锄头文库上搜索。
1、单片机c语言欢迎进入51单片机学习网论坛讨论本站新域名开通WWW.51C51.COM 中国单片机编程技术普及推广第一站!25点阵式LED“09”数字显示技术1 实验任务利用8X8点阵显示数字0到9的数字。2 电路原理图图4.25.13 硬件系统连线(1) 把“单片机系统”区域中的P1端口用8芯排芯连接到“点阵模块”区域中的“DR1DR8”端口上;(2) 把“单片机系统”区域中的P3端口用8芯排芯连接到“点阵模块”区域中的“DC1DC8”端口上;4 程序设计内容(1) 数字09点阵显示代码的形成如下图所示,假设显示数字“0”1 2 3 4 5 6 7 800 00 3E 41 41 41 3E
2、00因此,形成的列代码为 00H,00H,3EH,41H,41H,3EH,00H,00H;只要把这些代码分别送到相应的列线上面,即可实现“0”的数字显示。送显示代码过程如下所示送第一列线代码到P3端口,同时置第一行线为“0”,其它行线为“1”,延时2ms左右,送第二列线代码到P3端口,同时置第二行线为“0”,其它行线为“1”,延时2ms左右,如此下去,直到送完最后一列代码,又从头开始送。数字“1”代码建立如下图所示1 2 3 4 5 6 7 8其显示代码为 00H,00H,00H,00H,21H,7FH,01H,00H数字“2”代码建立如下图所示1 2 3 4 5 6 7 800H,00H,2
3、7H,45H,45H,45H,39H,00H数字“3”代码建立如下图所示1 2 3 4 5 6 7 800H,00H,22H,49H,49H,49H,36H,00H数字“4”代码建立如下图所示1 2 3 4 5 6 7 800H,00H,0CH,14H,24H,7FH,04H,00H数字“5”代码建立如下图所示1 2 3 4 5 6 7 800H,00H,72H,51H,51H,51H,4EH,00H数字“6”代码建立如下图所示1 2 3 4 5 6 7 800H,00H,3EH,49H,49H,49H,26H,00H数字“7”代码建立如下图所示1 2 3 4 5 6 7 800H,00H,4
4、0H,40H,40H,4FH,70H,00H数字“8”代码建立如下图所示1 2 3 4 5 6 7 800H,00H,36H,49H,49H,49H,36H,00H数字“9”代码建立如下图所示1 2 3 4 5 6 7 800H,00H,32H,49H,49H,49H,3EH,00H5 汇编源程序TIMEQU 30HCNTAEQU 31HCNTBEQU 32HORG 00HLJMP STARTORG 0BHLJMP T0XORG 30HSTART:MOV TIM,#00HMOV CNTA,#00HMOV CNTB,#00HMOV TMOD,#01HMOV TH0,#(65536-4000)/2
5、56MOV TL0,#(65536-4000) MOD 256SETB TR0SETB ET0SETB EASJMP $T0X:MOV TH0,#(65536-4000)/256MOV TL0,#(65536-4000) MOD 256MOV DPTR,#TABMOV A,CNTAMOVC A,A+DPTRMOV P3,AMOV DPTR,#DIGITMOV A,CNTBMOV B,#8MUL ABADD A,CNTAMOVC A,A+DPTR MOV P1,AINC CNTAMOV A,CNTACJNE A,#8,NEXTMOV CNTA,#00HNEXT:INC TIMMOV A,TIMC
6、JNE A,#250,NEXMOV TIM,#00HINC CNTBMOV A,CNTBCJNE A,#10,NEXMOV CNTB,#00HNEX:RETITAB:DB 0FEH,0FDH,0FBH,0F7H,0EFH,0DFH,0BFH,07FHDIGIT:DB 00H,00H,3EH,41H,41H,41H,3EH,00HDB 00H,00H,00H,00H,21H,7FH,01H,00HDB 00H,00H,27H,45H,45H,45H,39H,00HDB 00H,00H,22H,49H,49H,49H,36H,00HDB 00H,00H,0CH,14H,24H,7FH,04H,00
7、HDB 00H,00H,72H,51H,51H,51H,4EH,00HDB 00H,00H,3EH,49H,49H,49H,26H,00HDB 00H,00H,40H,40H,40H,4FH,70H,00HDB 00H,00H,36H,49H,49H,49H,36H,00HDB 00H,00H,32H,49H,49H,49H,3EH,00HEND6C语言源程序#include unsigned char code tab=0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f;unsigned char code digittab108=0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00,/0 0x00,0x00,0x00,0x00,0x21,0x7f,0x01,0x00,/1 0x00,0x00,0x27,0x45,0x45,0x45,0x39,0x00,/2 0x00,0x00,0x22,0x49,0x49,0x49,0x36,0x00,/3 0x00,0x00,0x0c,0x14,0x24,0x7f,0x04,0x00,/4 0x00,0x00,0x72,0x51,0x51,0x51,0x4e,0x00,/5 0x00,0x00,0x3e,0x49,0x49,0x49,0x26,0x00,/6