📄 shizhl.c
字号:
#include<reg51.h>
unsigned char table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char second,minute,hour,dpp,delete;
unsigned char delay;
unsigned char count=0,a=0;
unsigned char vot[4];
void fill(void);
void display(void);
void main(void)
{
unsigned char temp1;
second=52;
minute=59;
hour=14;
TMOD=0x00;
TH0=0x06;
TL0=0x0c;
P0=0xff;
EA=1;
ET0=1;
TR0=1;
P2=0x00;
dpp=0x80;
while(1)
{
temp1=hour/10;
if(temp1==0) delete=0xf7;
else delete=0xff;
fill();
display();
//P2=0x01;
}
}
void time0(void) interrupt 1 using 1
{
TH0=0x06;
TL0=0x0c;
if(++a==63) {dpp=0x00;a=0;}
if(++count==126)
{
count=0;
second++;
dpp=0x80;
if(second==60)
{
second=0;
minute++;
if(minute==60)
{
minute=0;
hour++;
if(hour==24)
{
hour=0;
}
}
}
}
}
void fill(void)
{
vot[3]=table[hour/10];
vot[2]=table[hour%10];
vot[1]=table[minute/10]+dpp;
vot[0]=table[minute%10]+dpp;
}
void display(void)
{
P0=vot[0];
P2=0x01&delete;
for(delay=0;delay<200;delay++);
P2=0x00;
P0=vot[1];
P2=0x02&delete;
for(delay=0;delay<200;delay++);
P2=0x00;
P0=vot[2];
P2=0x04&delete;
for(delay=0;delay<200;delay++);
P2=0x00;
P0=vot[3];
P2=0x08&delete;
for(delay=0;delay<200;delay++);
P2=0x00;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -