#include <reg52.h>
#define u8 unsigned char
#define u16 unsigned int
sbit P10=P1^0;
sbit P11=P1^1;
sbit P12=P1^2;
sbit P13=P1^3;
u8 ge,shi,bai,qian,jishu=0;
u8 code biaoge[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
void delayms(u16 t);
void display(u16 d);
void main()
{
u8 i=0;
u16 shuju=0;
while(i<50)
{
i++;
display(2345);
}
while(1)
{
display(shuju);
jishu++;
if(jishu>5)
{
jishu=0;
shuju++;
if(shuju>10000);
shuju=0;
}
}
}
void delayms(u16 t)
{
u16 i,j;
for(i=0;i<t;i++)
for(j=0;j<114;j++);
}
void display(u16 d)
{
qian=(u8)d/1000;
bai=(u8)d%1000/100;
shi=(u8)d%100/10;
ge=(u8)d%10;
P13=0;
P0=biaoge[ge];
delayms(500);
P13=1;
P0=0xff;
P12=0;
P0=biaoge[shi];
delayms(500);
P12=1;
P0=0xff;
P11=0;
P0=biaoge[bai];
delayms(500);
P11=1;
P0=0xff;
P10=0;
P0=biaoge[qian];
delayms(500);
P10=1;
P0=0xff;
}
|