單片機(jī)鬧鐘程序及PROTUES仿真文件
下面是仿真圖,芯片是用的51單片機(jī):
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;
}
}
評(píng)論