#include<reg51.h>
sbit P12=P1^2;
sbit P13=P1^3;
unsigned char code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xff};
void DelayMS(unsigned int x)
{
unsigned char t;
while(x--)
for(t=0;t<120;t++);
}
void main()
{
unsigned int i=0;
unsigned char j;
P0=0x00;
while(1)
{
i=i+1;
if(i>99)
i=0;
for(j=0;j<25;j++)
{
P12=1;
P13=0;
P0=DSY_CODE[i%10] ;
DelayMS(10);
P12=0;
P13=1;
P0=DSY_CODE[i/10%10] ;
DelayMS(10);
}
}
}
51单片机:在2位数码管上循环显示00-99,间隔0.5秒
于 2019-10-14 19:13:06 首次发布