本帖最后由 飞鱼seraet 于 2020-5-5 21:11 编辑
#include<reg52.h>
unsigned char code DuanMa[16]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x80,0xc6,0xc0,0x86,0x8e,};
unsigned char number;
void Delay(unsigned int t)
{
while(t--);
}
void DisplaySMG(unsigned char dat,unsigned char pos)
{
P2=(P2&0x1f)|0xc0;
P0=0x01<<pos;
P2=(P2&0x1f)|0xe0;
P0=dat;
}
void dynamic()
{
DisplaySMG(DuanMa[number/100],1);
Delay(200);
DisplaySMG(DuanMa[number%100/10],2);
Delay(200);
DisplaySMG(DuanMa[number%10],3);
Delay(200);
}
void delay2(unsigned char t)
{
while(t--);
{
dynamic();
}
}
void main()
{ number=0x64;
while(1)
{
Delay(200);
dynamic();
number--;
if(number=0)
{
number=100;
}
delay2(60);
}
}
|