#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;
float xx=0;
uchar yy=0;
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
TMOD=0x11;
TH0=(65535-50000)/255;//设置初始值
TL0=(65535-50000)%255;
TH1=(65535-50000)/255;
TL1=(65535-50000)%255;
EA=1;//打开总中断
ET0=1;//打开定时器0中断
ET1=1;//开定时器1中断
TR1=1;//定时器一开始计数
TR0=1;//定时器零开始计数
PT1=0;
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;
}
}
*/
}
void timer1() interrupt 3 //定时器一中断
{
TH1=(65535-50000)/255;
TL1=(65535-50000)%255;
num--;
if(num==0)
{
num=20;
xx++;
if(xx==10)//一小时
{xx=0;
//yy++;
// if(yy==10)
{
ring=0;
//delay(1000000);
//ring=1;
}
}
}
}
阅读(643) | 评论(0) | 转发(0) |