定义和显示函数如下
#include <REG52.H>
#define uint unsigned int
#define uchar unsigned char
#define Hidden 16 //DispTab[15]=0xff
uchar ms,shij,miao;
uchar shu1,shu2,shu_f;
bit a1;
sbit s1=P3^2;
sbit s2=P3^3;
sbit s3=P3^4;
sbit s4=P3^5;
sbit lin=P3^7;
sbit w1=P2^0;
sbit w2=P2^1;
sbit w3=P2^2;
sbit w4=P2^3;
sbit w5=P2^4;
sbit w6=P2^5;
sbit w7=P2^6;
sbit w8=P2^7;
uchar code su[]={
0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90
};
void delay(uchar ms)
{ //
uchar i ;
while(ms--)
{
for(i = 0 ; i<250;i++) ;
}
}
void xianshi()
{
P0=su[shij%100/10];
w1=1;
delay(1);
w1=0;
P0=su[shij%10];
w2=1;
delay(1);
w2=0;
P0=su[miao%100/10];
w3=1;
delay(1);
w3=0;
P0=su[miao%10];
w4=1;
delay(1);
w4=0;
P0=su[shu1%100/10];
w5=1;
delay(1);
w5=0;
P0=su[shu1%10];
w6=1;
delay(1);
w6=0;
P0=su[shu2%100/10];
w7=1;
delay(1);
w7=0;
P0=su[shu2%10];
w8=1;
delay(1);
w8=0;
}
|