谁能给四位数码管动态显示程序,最好详解
发布网友
发布时间:2022-05-06 18:36
我来回答
共1个回答
热心网友
时间:2023-10-15 08:43
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
sbit anXuan = P2^6;
sbit weiXuan = P2^7;
uchar anXuanTable[]={ 0x06,0x5b,0x4f,0x66 };
void delay(uchar ms) //延时
{
uchar i,j;
for(i=0;i<ms;i++)
for(j=0;j<112;j++)
;
}
void main()
{
uchar tmpD=0;
uchar tmpW=0xfe;
while(1)
{
uchar i;
for(i=0;i<4;i++)
{
P0 = anXuanTable[tmpD%4];
anXuan = 1;
anXuan = 0;
P0 = tmpW;
weiXuan = 1;
weiXuan = 0;
tmpW=_crol_(tmpW,1);
tmpD+=1;
delay(1);
}
tmpW=0xfe;
}
}