//提示:k1k2k3k4分别是:小时。分钟。秒钟的调理功用。守时时刻的显现功用。k5k6分别是设定第二时刻定为0:01:00,启用或许封闭闹钟,
下面是仿真图,芯片是用的51单片机:
PROTUES工程文件能够从http://www.51hei.com/bbs/dpj-24552-1.html下载
下面是源程序:
#include”AT89X52.H”
#define uchar unsigned char
uchar code seg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xbf}; //断码
uchar codepos[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; //微码
sbit k1=P1^0;
sbit k2=P1^1;
sbit k3=P1^2;
sbit k4=P1^3;
sbit k5=P1^4;
sbit jidianqi1=P1^5;
sbit k6=P1^6;
sbit led=P1^7;
uchar k[8]={0,0,16,0,0,16,0,0}; //01234567
uchar code seg00[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0xbf}; //断码
uchar code pos00[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}; //微码
uchar k00[8]={0,0,16,0,0,16,0,0}; //01234567
uchar second;
uchar minite;
uchar hour;
uchar num;
uchar naozhongqiyongFlag;
uchar second00;
uchar minite00;
uchar hour00;
uchar num00;
////////////////////////////////////////////////////////////////////////////////////
void TimeCompate(void)
{
if(naozhongqiyongFlag)
{
if((second00==0)&&(minite00==1)&&(hour00==0)) ///&&(minite00<=2),,,(naozhongqiyongFlag==1)&&,, led=1
{
jidianqi1=0;
}
else if((second00==5)&&(minite00==42)&&(hour00==0))
{
jidianqi1=1; naozhongqiyongFlag=~naozhongqiyongFlag; led=~led;
}
}
/*if(hour00!=0)
{ jidianqi1=1; naozhongqiyongFlag=0;
}
if(hour00==0)
{
if(minite00<1)
{ jidianqi1=1; naozhongqiyongFlag=0;
}
else if(minite00>2)
{ jidianqi1=1; naozhongqiyongFlag=0;
}
else
{
jidianqi1=0;
}
}