Protues中用AT89C51驱动6个7段数码管7SEG-MPX6-CA-BLUE的使用如图所示ABCDEFG为7段LED的输入端口,DP为小数点,123456为片先信号,当1为高电平时则选中第一个数码管,2为高电平时则选中第二个数码管,以此类推。ATC89C51组成最小系统驱动数码管电路本电路中用AT89C51构成一最小系统,然后用P1.0到P1.5的6个引脚输出片选信号,P2.0到P2.6的7个引脚输出数据,硬件电路就是这么简单了。LEDBUFEQU30H;为显示数据开辟内存单元ORG0000HLJMPMAINORG000BHLJMPTIME0ORG0030HTABLE:DB0C0H,0F9H,0A4H,0B0H,99HDB92H,82H,0F8H,80H,90H;7段数码管译码表MAIN:MOVSP,#70H;初始化堆栈MOVLEDBUF,#5MOVLEDBUF+1,#2MOVLEDBUF+2,#0MOVLEDBUF+3,#1MOVLEDBUF+4,#3MOVLEDBUF+5,#1MOVLEDBUF+6,#4;写入要显示的数字MOVR0,#LEDBUF;将ledbuf的首地址给R0MOVDPTR,#TABLE;将TABLE的首是址给DPTRMOVR2,#06H;R2作为循环次数寄存器MOVR1,#01H;R1中放片选信号MOVTMOD,#01H;定时器0工作在方式1MOVTH0,#0DFHMOVTL0,#0B0H;初始代定时器0SETBTR0;开定时器0SETBEA;开总中断SETBET0;开定时器0中断SJMP$;动态停机TIME0:DJNZR2,LOOP1;循环6次后回到初始值继续循环,小于6次跳到LOOP1MOVR2,#06HMOVR1,#01HMOVR0,#LEDBUF;初始化数据LOOP1:MOVTH0,#0DFHMOVTL0,#0B0H;初始化定时器0MOVA,R1MOVP1,ARLAMOVR1,A;将R1中片选信号输入P1并且使其数据左移一位MOVA,@R0MOVCA,@A+DPTRMOVP2,AINCR0;通过查表将ledbuf中数据送往P2RETIEND改动ledbuf中的数字则可显示想要显示的数据,改动如下LEDBUFEQU30H;为显示数据开辟内存单元ORG0000HLJMPMAINORG000BHLJMPTIME0ORG0030HTABLE:DB0C0H,0F9H,0A4H,0B0H,99HDB92H,82H,0F8H,80H,90H;7段数码管译码表MAIN:MOVSP,#70H;初始化堆栈MOVLEDBUF,#1MOVLEDBUF+1,#2MOVLEDBUF+2,#3MOVLEDBUF+3,#4MOVLEDBUF+4,#5MOVLEDBUF+5,#6MOVLEDBUF+6,#7;写入要显示的数字MOVR0,#LEDBUF;将ledbuf的首地址给R0MOVDPTR,#TABLE;将TABLE的首是址给DPTRMOVR2,#06H;R2作为循环次数寄存器MOVR1,#01H;R1中放片选信号MOVTMOD,#01H;定时器0工作在方式1MOVTH0,#0DFHMOVTL0,#0B0H;初始代定时器0SETBTR0;开定时器0SETBEA;开总中断SETBET0;开定时器0中断SJMP$;动态停机TIME0:DJNZR2,LOOP1;循环6次后回到初始值继续循环,小于6次跳到LOOP1MOVR2,#06HMOVR1,#01HMOVR0,#LEDBUF;初始化数据LOOP1:MOVTH0,#0DFHMOVTL0,#0B0H;初始化定时器0MOVA,R1MOVP1,ARLAMOVR1,A;将R1中片选信号输入P1并且使其数据左移一位MOVA,@R0MOVCA,@A+DPTRMOVP2,AINCR0;通过查表将ledbuf中数据送往P2RETIEND结果下如: