新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)鬧鐘程序及PROTUES仿真文件

單片機(jī)鬧鐘程序及PROTUES仿真文件

作者: 時(shí)間:2016-12-01 來(lái)源:網(wǎng)絡(luò) 收藏
//提示:k1k2k3k4分別是:小時(shí)。分鐘。秒鐘的調(diào)節(jié)功能。定時(shí)時(shí)間的顯示功能。k5k6分別是設(shè)定第二時(shí)間定為0:01:00,啟用或者關(guān)閉鬧鐘,

下面是仿真圖,芯片是用的51單片機(jī):


PROTUES工程文件可以從http://www.51hei.com/bbs/dpj-24552-1.html下載

本文引用地址:http://m.butianyuan.cn/article/201612/324567.htm

下面是源程序:
#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;
}
}


上一頁(yè) 1 2 3 下一頁(yè)

評(píng)論


技術(shù)專(zhuān)區(qū)

關(guān)閉