#include <REGX52.H>
unsigned char code DSY_CODE[]={0xc0,0xf9,0xa4,0xb0,0x99,0x82,0xf8,0x80,0x90};
unsigned char num[]={8,9,5,2};
void Delayms(unsigned int x)
{
unsigned int i,j;
for(i=0;i<x;i++)
{
for(j=0;j<120;j++);
}
}
void main()
{
while(1)
{
unsigned char temp,turn;
P0=0xff;//段码
turn=0xef;//位码 1110 1111 P2口高4位
for(temp=0;temp<4;temp++)
{
P2=0xff;
P0=DSY_CODE[num[temp]];
P2=turn;
Delayms(5);
turn=turn<<1;
}
}
}
数码管动态显示
于 2024-04-16 21:13:15 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)