單片機(jī)點(diǎn)陣式LED簡單圖形顯示技術(shù)
1.實(shí)驗(yàn)任務(wù)
本文引用地址:http://butianyuan.cn/article/186014.htm在8X8點(diǎn)陣式LED顯示“★”、“●”和心形圖,通過按鍵來選擇要顯示的圖形。
2.電路原理圖
3.硬件系統(tǒng)連線
(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.程序設(shè)計(jì)內(nèi)容
(1).“★”在8X8LED點(diǎn)陣上顯示圖如下圖所示
12H,14H,3CH,48H,3CH,14H,12H,00H
(2).“●”在8X8LED點(diǎn)陣上顯示圖如下圖所示
00H,00H,38H,44H,44H,44H,38H,00H
(3).心形圖在8X8LED點(diǎn)陣上顯示圖如下圖所示
30H,48H,44H,22H,44H,48H,30H,00H
5.匯編源程序
CNTAEQU 30H
COUNTEQU 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;
}
}
更多資訊請(qǐng)關(guān)注:21ic模擬頻道
評(píng)論