共阳数码管的显示程序

共阳数码管的显示程序,第1张

下面程序中P0接段码,P2接位选,共阳极

#include <reg52.h>

#include <intrins.h>

#define uchar unsigned char

#define uint unsigned int

uchar code DSY_CODE[]=

{

0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90

}

void DelayMS(uint x)

{

uchar i

while(x--)

{

for(i=200i>0i--)

}

}

void main()

{

uchar i,k=0x80

while(1)

{

for(i=8i>0i--)

{

P2=0xff

k=_crol_(k,1)

P0=DSY_CODE[8-i]

P2=k

DelayMS(3)

}

}

}

DISPLAY: MOV DPTR,#DAT1查表显示程序,利用P0口做段选码口输出/P2低三位做位选码 输出

MOV A,R3

MOVC A,@A+DPTR

MOV P2,#01H

MOV P0,A

ACALL DELAY2

MOV DPTR,#DAT2

MOV A,R5

MOVC A,@A+DPTR

MOV P2,#02H

MOV P0,A

ACALL DELAY2

MOV A,R4

MOVC A,@A+DPTR

MOV P2,#04H

MOV P0,A

ACALL DELAY2

RET

DAT1: DB 0ffh,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h,0ffH,8eH

"灭","1","2","3","4","5","6","7","8","9","灭","F"

DAT2: DB 0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h,0ffH,8eH


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11659502.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-17
下一篇 2023-05-17

发表评论

登录后才能评论

评论列表(0条)

保存