單片機IO并行口直接驅(qū)動LED顯示技術(shù)
6.匯編源程序
ORG 0
START: MOV R1,#00H
NEXT: MOV A,R1
MOV DPTR,#TABLE
MOVC A,@A+DPTR
MOV P0,A
LCALL DELAY
INC R1
CJNE R1,#10,NEXT
LJMP START
DELAY: MOV R5,#20
D2: MOV R6,#20
D1: MOV R7,#248
DJNZ R7,$
DJNZ R6,D1
DJNZ R5,D2
RET
TABLE: DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH
END
7. C語言源程序
#include AT89X51.H>
unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,
0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char dispcount;
void delay02s(void)
{
unsigned char i,j,k;
for(i=20;i>0;i--)
for(j=20;j>0;j--)
for(k=248;k>0;k--);
}
void main(void)
{
while(1)
{
for(dispcount=0;dispcount10;dispcount++)
{
P0=table[dispcount];
delay02s();
}
}
}
51單片機相關(guān)文章:51單片機教程
led顯示器相關(guān)文章:led顯示器原理
評論