8X8LED點(diǎn)陣顯示原理與編程源代碼
本文引用地址:http://m.butianyuan.cn/article/167770.htm
5.匯編源程序
ORG00H
START:NOP
MOVR3,#3
LOP2:MOVR4,#8
MOVR2,#0
LOP1:MOVP1,#0FFH
MOVDPTR,#TABA
MOVA,R2
MOVCA,@A+DPTR
MOVP3,A
INCR2
LCALLDELAY
DJNZR4,LOP1
DJNZR3,LOP2
MOVR3,#3
LOP4:MOVR4,#8
MOVR2,#7
LOP3:MOVP1,#0FFH
MOVDPTR,#TABA
MOVA,R2
MOVCA,@A+DPTR
MOVP3,A
DECR2
LCALLDELAY
DJNZR4,LOP3
DJNZR3,LOP4
MOVR3,#3
LOP6:MOVR4,#8
MOVR2,#0
LOP5:MOVP3,#00H
MOVDPTR,#TABB
MOVA,R2
MOVCA,@A+DPTR
MOVP1,A
INCR2
LCALLDELAY
DJNZR4,LOP5
DJNZR3,LOP6
MOVR3,#3
LOP8:MOVR4,#8
MOVR2,#7
LOP7:MOVP3,#00H
MOVDPTR,#TABB
MOVA,R2
MOVCA,@A+DPTR
MOVP1,A
DECR2
LCALLDELAY
DJNZR4,LOP7
DJNZR3,LOP8
LJMPSTART
DELAY:MOVR5,#10
D2:MOVR6,#20
D1:MOVR7,#248
DJNZR7,$
DJNZR6,D1
DJNZR5,D2
RET
TABA:DB0FEH,0FDH,0FBH,0F7H,0EFH,0DFH,0BFH,07FH
TABB:DB01H,02H,04H,08H,10H,20H,40H,80H
END
6. C語言源程序
#includeAT89X52.H>
unsignedcharcodetaba[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsignedcharcodetabb[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
voiddelay(void)
{
unsignedchari,j;
for(i=10;i>0;i--)
for(j=248;j>0;j--);
}
voiddelay1(void)
{
unsignedchari,j,k;
for(k=10;k>0;k--)
for(i=20;i>0;i--)
for(j=248;j>0;j--);
}
voidmain(void)
{
unsignedchari,j;
while(1)
{
for(j=0;j3;j++)//from left to right 3 time
{
for(i=0;i8;i++)
{
P3=taba[i];
P1=0xff;
delay1();
}
}
for(j=0;j3;j++)//from right to left 3 time
{
for(i=0;i8;i++)
{
P3=taba[7-i];
P1=0xff;
delay1();
}
}
for(j=0;j3;j++)//from top to bottom 3 time
{
for(i=0;i8;i++)
{
P3=0x00;
P1=tabb[7-i];
delay1();
}
}
for(j=0;j3;j++)//from bottom to top 3 time
{
for(i=0;i8;i++)
{
P3=0x00;
P1=tabb[i];
delay1();
}
}
}
}
電子鎮(zhèn)流器相關(guān)文章:電子鎮(zhèn)流器工作原理
評論