#include
#define uint unsigned int
#define uchar unsigned char
uchar t[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xbf};
sbit key1=P1^0;
sbit key2=P1^1;
sbit key3=P1^2;
sbit key4=P1^3;
sbit ring=P2^1;
int aa,bb,cc;
uchar cnt=20;
uchar num=20;
uchar cntt=0;
uchar temp;
void init()
{
aa=21;
bb=23;
cc=30;
}
void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=11;y>0;y--);
}
/*void key()
{
if(key2==0)
{
delay(5);
if(key2==1)
{
delay(5);
aa++;
delay(5);
}
}
} */
void display()
{
{
P3=0xfe;
P0=t[aa/10];
delay(5);
P3=0xfd;
P0=t[aa%10];
delay(5);
P3=0xfb;
P0=t[10];
delay(5);
P3=0xf7;
P0=t[bb/10];
delay(5);
P3=0xef;
P0=t[bb%10];
delay(5);
P3=0xdf;
P0=t[10];
delay(5);
P3=0xbf;
P0=t[cc/10];
delay(5);
P3=0x7f;
P0=t[cc%10];
delay(5);
}
/*P3=0x7f;
P0=t[1];
//delay(5);*/
}
void main()
{
init();
TMOD=0x01;//选定时器0,工作方式1
TH0=(65535-50000)/255;//设置初始值
TL0=(65535-50000)%255;
EA=1;//打开总中断
ET0=1;//打开定时器0中断
TR0=1;//定时器开始计数
while(1)
{
display();
if(cnt==0)
{
cnt=20;
cc++;
if(cc>=60)
{
cc=0;
bb++;
if(bb>=60)
{
bb=0;
aa++;
if(aa>=23)
{
aa=0;
}
}
}
}
}
}
void timer0() interrupt 1
{
TH0=(65535-50000)/255;
TL0=(65535-50000)%255;
cnt--;
//key();
////////////////////////////key2222222222
if(key2==0)
{
ring=0;
delay(50);
//if(key2==1)
{if(aa>=23)
aa=0;
aa++;
delay(50);
}
ring=1;
}
///////////////////////////key33333333333333
if(key3==0)
{
ring=0;
delay(50);
//if(key2==1)
{if(bb>=60)
bb=0;
bb++;
delay(50);
}
ring=1;
}
if(key4==0)
{
ring=0;
delay(50);
//if(key2==1)
{if(bb<=0)
bb=59;
bb--;
delay(50);
}
ring=1;
}
/*P1=0xfe;
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)
{
delay(5);
temp=P1;
temp=temp&0xf0;
while(temp!=0xf0)
{
temp=P1;
switch(temp)
{
case 0xee:aa++;
break;
case 0xde:aa--;
break;
case 0xbe:bb++;
break;
case 0x7e:bb--;
break;
}
}
*/
}
阅读(841) | 评论(0) | 转发(0) |