本文包含原理图、PCB、源代码、封装库、中英文PDF等资源
您需要 登录 才可以下载或查看,没有账号?注册会员
×
Normal 0 7.8 磅 0 2 false false false MicrosoftInternetExplorer4
//主程序和定时器中断子程序
#include<reg51.h>
char mod[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
charsceond,minute,hour,i,k,l,j,x,y;
int u;
sbit P1_0=P1^0;
sbit P1_1=P1^1;
sbit P1_2=P1^2;
//延时程序
void delay()
{
unsigned int time,p;
for(time=30;time>0;time--)
for(p=0;p<10;p++);
}
//中断子程序
timer0 (void) interrupt 1 using 1
{
u++;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
}
//LED显示子程序
void xianshi()
{
if(u==20)
{
u=0;
sceond++;
while(sceond==60)
{
sceond=0;
minute++;
if(minute==60)
{
minute=0;
hour++ ;
if(hour==24)
{
hour=0;
}
}
}
}
x=hour%10;
y=hour/10;
l=minute%10;
j=minute/10;
i=sceond%10;
k=sceond/10;
P2=0x7f;
P0=mod;
delay();
P2=0xbf;
P0=mod[k];
delay();
P2=0xdf;
P0=0x40;
delay();
P2=0xef;
P0=mod[l];
delay();
P2=0xf7;
P0=mod[j];
delay();
P2=0xfb;
P0=0x40;
delay();
P2=0xfd;
P0=mod[x];
delay();
P2=0xfe;
P0=mod[y];
delay();
}
//按键控制子程序
void kongzhi()
{
if(P1_0==0)
{
TR0=0;
while(P1_0==0);
while(1)
{
if(P1_1==0)
{
sceond++;
if(sceond==60)
{
sceond=0;
}
}
while(P1_1==0);
if(P1_2==0)
{
sceond--;
if(sceond<0)
{
sceond=0;
}
}
while(P1_2==0);
i=sceond%10;
k=sceond/10;
P2=0x7f;
P0=mod;
delay();
P2=0xbf;
P0=mod[k];
delay();
if(P1_0==0)
{
while(P1_0==0);
while(1)
{
if(P1_1==0)
{
minute++;
while(minute==60)
{
minute=0;
}
}
while(P1_1==0); |