#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit p0=P2^5;
sbit p1=P2^1;
sbit p2=P2^2;
sbit p3=P2^3;
sbit p11=P1^1;//SUDUXINHAO
sbit p12=P1^2;//LED1
sbit p13=P1^3;//LED2
sbit p14=P1^4;//LED3
sbit p10=P1^0;//SHILIXINHAO
sbit p30=P3^0;//laba
sbit k1=P3^1;
sbit k2=P3^2;
sbit k3=P3^3;
sbit k4=P3^4;
sbit p23=P2^3;
sbit p24=P2^4;
uchar code led[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar code led0[10]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};
uint x,y,z,q,w,e,num2,t,v;
void delay(uint z);
void init();
void ledinit();
void init()
{
TMOD=0x01;
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
EA=1;
ET0=1;
TR0=1;
num2=0;
}
void ledinit()
{
p0=1;
p1=1;
p2=1;
p3=1;
}
void main()
{
init();
while(1)
{
v=(25000/t)*36;
x=v/100;
y=v%100;
z=x/10;//min shi
q=x%10;//min ge
w=y/10;//miao shi
e=y%10;//miao ge
ledinit();
p0=0;
P0=led[z];//min shi
delay(1);
ledinit();
p1=0;
P0=led[q];//min ge
delay(1);
ledinit();
p2=0;
P0=led0[w];
delay(1);//miao shi
ledinit();
p3=0;
P0=led[e];
delay(1);//miao ge
if(p11==0)
{p12=0;p13=0;p14=0;p30=0;}
if(p10==0)
{p12=0;p13=1;p14=0;p30=1;}
if(k1==0){p23=1;p24=0;} //zhengzhuan
if(k1==0){p23=0;p24=1;}//fanzhuan
if(k1==0){p23=1;p24=1;}//shache
if(k1==0){p23=0;p24=0;}//tingzhi
}
}
void delay(uint z)//Ñóê±1ms
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void time0() interrupt 1 using 1//¶¨ê±ÖD¶Ï
{
uint num1,num2;
TH0|=(65536-918)/256;
TL0|=(65536-918)%256;
num1++;
if(num1==1)
{
num1=0;
if(p11==0)
{num2++;
t=num2;
}
else
{num2=0;}
}
}
|