您的位置 首页 编程

单片机闹钟程序及PROTUES仿真文件

提示:k1k2k3k4分别是:小时。分钟。秒钟的调节功能。定时时间的显示功能。k5k6分别是设定第二时间定为0:01:00,启用或者关闭闹钟,下

//提示: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;
}
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/fangan/biancheng/317821.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部