26. 點(diǎn)陣式LED簡單圖形顯示技術(shù)
在8X8點(diǎn)陣式LED顯示“★”、“●”和心形圖,通過按鍵來選擇要顯示的圖形。
2.電路原理圖
(1).把“單片機(jī)系統(tǒng)”區(qū)域中的P1端口用8芯排芯連接到“點(diǎn)陣模塊”區(qū)域中的“DR1-DR8”端口上;
(2).把“單片機(jī)系統(tǒng)”區(qū)域中的P3端口用8芯排芯連接到“點(diǎn)陣模塊”區(qū)域中的“DC1-DC8”端口上;
(3).把“單片機(jī)系統(tǒng)”區(qū)域中的P2.0/A8端子用導(dǎo)線連接到“獨(dú)立式鍵盤”區(qū)域中的SP1端子上;
4.
5.匯編源程序
CNTAEQU30H
COUNTEQU31H
ORG00H
LJMPSTART
ORG0BH
LJMPT0X
ORG30H
START:MOVCNTA,#00H
MOVCOUNT,#00H
MOVTMOD,#01H
MOVTH0,#(65536-4000)/256
MOVTL0,#(65536-4000)MOD256
SETBTR0
SETBET0
SETBEA
WT:JBP2.0,WT
MOVR6,#5
MOVR7,#248
D1:DJNZR7,$
DJNZR6,D1
JBP2.0,WT
INCCOUNT
MOVA,COUNT
CJNEA,#03H,NEXT
MOVCOUNT,#00H
NEXT:JNBP2.0,$
SJMPWT
T0X:NOP
MOVTH0,#(65536-4000)/256
MOVTL0,#(65536-4000)MOD256
MOVDPTR,#TAB
MOVA,CNTA
MOVCA,@A+DPTR
MOVP3,A
MOVDPTR,#GRAPH
MOVA,COUNT
MOVB,#8
MULAB
ADDA,CNTA
MOVCA,@A+DPTR
MOVP1,A
INCCNTA
MOVA,CNTA
CJNEA,#8,NEX
MOVCNTA,#00H
NEX:RETI
TAB:DB0FEH,0FDH,0FBH,0F7H,0EFH,0DFH,0BFH,07FH
GRAPH:DB12H,14H,3CH,48H,3CH,14H,12H,00H
DB00H,00H,38H,44H,44H,44H,38H,00H
DB30H,48H,44H,22H,44H,48H,30H,00H
END
6.C語言源程序
#include
unsignedcharcodetab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsignedcharcodegraph[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}
};
unsignedcharcount;
unsignedcharcnta;
voidmain(void)
{
unsignedchari,j;
TMOD=0x01;
TH0=(65536-4000)/256;
TL0=(65536-4000)%256;
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);
}
}
}
}
voidt0(void)interrupt1using0
{
TH0=(65536-4000)/256;
TL0=(65536-4000)%256;
P3=tab[cnta];
P1=graph[count][cnta];
cnta++;
if(cnta==8)
{
cnta=0;
}
}
評論