#include <reg51.h>
#define LaoBai unsigned char
#define Liyuchao unsigned int
LaoBai code GY[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
Liyuchao second=0,minter=0,hour=12;
Liyuchao sshi,sge,mge,mshi,hshi,hge;
static char ji_shu_zhong_duan_ci_shu=0;
sbit P21=P2^1;
sbit P22=P2^2;
sbit P23=P2^3;
sbit P24=P2^4;
sbit P25=P2^5;
sbit P26=P2^6;
sbit P27=P2^7;
sbit P20=P2^0;
sbit P10=P1^0;
sbit P11=P1^1;
void delay()
{
LaoBai i;
for(i=0;i<15;i++);
}
void int1()interrupt 1 using 2
{
TH0=0x4C;
TL0=0x00;
ji_shu_zhong_duan_ci_shu++;
if(minter==60)minter=0;
if(hour==24)hour=0;
}
void main()
{
TMOD=0x01;
TH0=0x4C;
TL0=0x00;
EA=1;
ET0=1;
TR0=1;
for(;;)
{
sshi=second/10;
sge=second%10;
mshi=minter/10;
mge=minter%10;
hshi=hour/10;
hge=hour%10;
P0=GY[sge];
P27=1;
delay();
P27=0;
P0=GY[sshi];
P26=1;
delay();
P26=0;
P0=0xBF;
P25=1;
delay();
P25=0;
P0=GY[mge];
P24=1;
delay();
P24=0;
P0=GY[mshi];
P23=1;
delay();
P23=0;
P0=0xBF;
P22=1;
delay();
P22=0;
P0=GY[hge];
P21=1;
delay();
P21=0;
P0=GY[hshi];
P20=1;
delay();
P20=0;
if(ji_shu_zhong_duan_ci_shu==20)
{ ji_shu_zhong_duan_ci_shu=0;
second++;
if(second==60)
{
second=0;minter++;
if(minter==60)
{
minter=0;hour++;
if(hour==24)
hour=0;
}
}
else if(P10==0)minter++;
else if(P11==0)hour++;
}
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>