【035】一位数码管循环显示多个数字2007-05-05 16:20:00
【评论】
【打印】
【字体:大 中 小】
本文链接:http://blog.pfan.cn/wentao/25589.html
org 0000h
ajmp start
org 0030h
start: mov 30h,#0
mov dptr,#table
lop: mov a,30h
movc a,@a+dptr
mov p0,a
mov p2,#0xfe
lcall d500ms
inc 30h
mov a,30h
cjne a,#16,lop
ajmp start
d500ms:
mov r5, #4
temp1: mov r6, #244
temp2: mov r7, #255
djnz r7, $
djnz r6, temp2
djnz r5, temp1
ret
table: db 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8
db 0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e
end
#include <reg51.h>
#define uchar unsigned char
void delay_ms(uchar ms);
uchar code dis_code[16] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,
0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
void main()
{
uchar i;
P2 = 0xfe;
while(1)
{
for(i = 0; i < 16; i++)
{
P0 = dis_code[i];
delay_ms(250);
delay_ms(250);
}
}
}
void delay_ms(uchar ms)
{
uchar i;
while(ms--)
for(i = 0; i < 124; i++);
}
阅读(6021) | 评论(4)
版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!
评论