‍-         &nb,咨信网zixin.com.cn" /> ‍-   &nbs"/>
收藏 分销(赏)

基于单片机数码管的电子钟含闹钟、整点报时.doc

上传人:二*** 文档编号:4570656 上传时间:2024-09-30 格式:DOC 页数:16 大小:36KB 下载积分:5 金币
下载 相关 举报
基于单片机数码管的电子钟含闹钟、整点报时.doc_第1页
第1页 / 共16页
本文档共16页,全文阅读请下载到手机保存,查看更方便
资源描述
<p><span id="_baidu_bookmark_start_0" style="display: none; line-height: 0px;">‍</span>- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;- 基于单片机数码管的电子钟〔郭天祥系列单片机〕 1、功能说明 〔1〕本电子钟可以显示当前时刻、年月日和闹钟时刻。不同时间的显示可以用key4来切换。 〔2〕、独立键盘key1-key4(左到右〕调节不同功能,7段数码管显示。 &nbsp; &nbsp; (3) 整点提示功能:当时间为整点时,蜂鸣器会滴滴滴响,响20秒; &nbsp; &nbsp; (4) 闹铃功能:本程序有闹铃功能,当定时时间到时,闹铃会滴滴滴报警,报警30秒; &nbsp; &nbsp; 〔5〕附加功能:当在闹铃和整点时,8个发光二极管会闪亮; &nbsp; &nbsp; 〔6〕时、分、秒之间和年、月、日之间也是用“.〞分割。 2、键盘控制 〔1〕key1-键移动调整单位,每按一次移动一个单位,可调整时分秒、年月日和闹钟时间。比方:在显示时分秒时,按下key1键,可通过key2和key3对‘秒’加减;再按一下key1,可对‘分’加减;再按一下key1,可对‘时’加减;再按key1,时间开场走动 〔2〕key2-加1;key3-减1; 〔3〕key4-键切换时分秒、年月日和闹铃时间的显示。比方:当前为时分秒,按一下key4,那么显示年月;再按一下,那么显示闹铃时间;再按一下,那么显示时分秒时间。 附录:C语言程序 //设计工程:带闹铃的电子钟 //功能: &nbsp;key1-键:开场/调时分秒/调年月日/调定时 // &nbsp; &nbsp; &nbsp; key2-键:加1 // &nbsp; &nbsp; &nbsp; key3-键:减1 // &nbsp; &nbsp; &nbsp; key4-键:切换页面 #include</p><reg52.h>#define uchar unsigned char #define uint unsigned int sbit dula=P2^6; sbit wela=P2^7; sbit key1=P3^4; sbit key2=P3^5; sbit key3=P3^6; sbit key4=P3^7; sbit bear=P2^3; uchar code table[]={0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e, 0x79,0x71}; uchar sec1,min1,hour1,year1,mon1,day1,temp1,temp2,sec2,min2,hour2; void keyscan(); void display(uchar hour,uchar min,uchar sec); void delay(uint z) { uint x,y; for(x=0;x&lt;z;x++) for(y=0;y&lt;110;y++); void=&quot;&quot; tmod=&quot;0X02;&quot; th0=&quot;6;&quot; tl0=&quot;6;&quot; ea=&quot;1;&quot; et0=&quot;1;&quot; tr0=&quot;1;&quot; hour1=&quot;=hour2&amp;&amp;min1==min2&amp;&amp;(sec1&quot; min1=&quot;=0)min1=60;min1--;break;&quot; sec1=&quot;=0)sec1=60;sec1--;break;&quot; year1=&quot;=0)year1=100;year1--;break;&quot; mon1=&quot;=1)mon1=13;mon1--;break;&quot; day1=&quot;=1)day1=31;day1--;break;&quot; uchar=&quot;&quot; s2=&quot;sec/10;&quot; s1=&quot;sec%10;&quot; m2=&quot;min/10;&quot; m1=&quot;min%10;&quot; h2=&quot;hour/10;&quot; h1=&quot;hour%10;&quot; dula=&quot;0;&quot; p0=&quot;0Xdf;&quot; wela=&quot;1;&quot; key1=&quot;=0)&quot; temp1=&quot;0;&quot; case=&quot;&quot; key2=&quot;=0)&quot; temp2=&quot;0;&quot; sec2=&quot;=0)sec2=60;sec2--;break;&quot; min2=&quot;=0)min2=60;min2--;break;&quot; hour2=&quot;=0)hour2=24;hour2--;break;&quot; key3=&quot;=0)&quot; key4=&quot;=0)&quot; uint=&quot;&quot;&gt;=sec2&amp;&amp;sec1&lt;sec2+30))||(min1==0&amp;&amp;sec1&lt;20)) { for(i=0;i&lt;20;i++) { bear=~bear; P1=~P1; switch(temp2) { case 0:display(hour1,min1,sec1);break; case 1:display(year1,mon1,day1);break; &nbsp; &nbsp;case 2:display(hour2,min2,sec2);break; } delay(30); } bear=1; P1=0xff; } } void main() { init(); while(1) { &nbsp; keyscan(); { if(key1==0 || key2==0 || key3==0 || key4==0 ) Bear=0 } alarm(); } } void time1()interrupt 1 { uint m; m++; if(m==3686) { m=0; &nbsp; &nbsp;sec1++; if(sec1==60) &nbsp;{ &nbsp; sec1=0; &nbsp; min1++; &nbsp; if(min1==60) { min1=0; hour1++; &nbsp; if(hour1==24) { &nbsp; &nbsp; hour1=0; &nbsp;day1++; &nbsp;if(day1==31) &nbsp;{ &nbsp; day1=1; &nbsp; mon1++; if(mon1==13) { mon1=1; year1++; if(year1==100) year1=0; } &nbsp;} } } } } } - &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; - word.zl- <!--110;y++);--></reg52.h>
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 学术论文 > 其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2025 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服