运用51单片机实现4位8段LED数码管的动态数字显示,写出C语言程序

2024年12月03日 05:37
有2个网友回答
网友(1):

#include
#define uchar unsigned char;
uchar distab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x00}; //0到f
uchar number,nn=0;
uchar dat[]={2,0,1,2,1,1,4,5,8,2};
void t0isr() interrupt 1
{
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
number++;
number%=4;
switch(number)
{
case 0:P2=0x08;P0=distab[nn];
break;
case 1:P2=0x04;P0=distab[nn+1];
break;
case 2:P2=0x02;P0=distab[nn+2];
break;
case 3:P2=0x01;P0=distab[nn+3];
break;
default:break;
}
nn++;
nn%=7;
}
main()
{
TMOD=0x01;
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
TR0=1;
ET0=1;
EA=1;
while(1);
}

网友(2):

又是来骗积分的。