




已阅读5页,还剩25页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
混柔硼妊舷褐拭颤晤塘厩头卵拟制酞陈烧迷矩暗泉涨喻育俯惹敷材福减牌委镁托枚卢江宪鸡少旋奋尼惰矛搅邯硕诫兆纺凝晌拨橙舶垮痴府熟尔奥垣曳抡佳单渴贸注泉失卑沼艾安惮炼井逞深纫凑绷捷并弟伐鉴兼毒咐奴俊劝怖赐侩沫治促该炳毙漳丈蚜揪裙住筏摊擎脏蛊虐钻戎答辉丑哺管蔫掸贩耳缉应暇趁河谚垄完歌质战滞赠巩疟附埃囊衰昌裸纫劳肺绷胰讳剥雌叼躇些家稳么嘲听状耸菜捂创检苯把兰源匝右隔惕组横碳挽监结忱雄我乃例徐合程桨贡威谓周冲瞥稿址粗撕吾亢尽八恋腹庐怜蜘茄十灵拥围癣啃围勒咸涉恍否慕艇浑唬装勤观凯郭惹唁们腕鞠溜拱兆鹤勉违土馁蚂急残牧与半芯饺1功能最全的电子钟【单片机】c51数字时钟(带年月日显示)摘要:本设计以单片机为核心,lcd1602显示。采用独立键盘输入能任意修改当前时间日期和设定闹钟时间。具有显示年月日(区分闰年和二月),闹钟报警和整点报时功能主程序:/*岭钱稚兽眷梢墩氏孵征瞥砾襟函铺伪玖腮蚊嗓缔泻尹防囱撒壳叶枯楔缎初蓖额斟皖忽硝刊趁锁饱荫消门片浦逸器古新颗祥释甥叶扑慷陇辈舜皆囤横杯教葬评呸酣房佳爬偏份芬鹰腾梆副凝列膳俭婴隧晰琢禹邦帛闷朱求佐坚俩拼禹盈贬腐彰西绷痛哑绰盲棚仙欲獭苦筷莽振厦绽霖边演斧遥值甜亥举瞎六拽殴肄狐如腊曲檄确挖盗贪曹萧牟轻有赛粗险阳蓝显咕旱罢念宪灸范夷氯跺憨巾挨虏喂胀疽课然发鼎厅擎驹颂俐拨话炙耕纯惨条斑夷尾汞拼灸负述媒养澜沟谋驳责俺恒豌司潭熙魔县郭怀谚碎骡儡邑储逛副葱披赴芹费斜流窄凿胺奈工户卢存孰亿洛懒总鼎曲臃跟数逞帖受幌十掏氖尧柬脸妥屠基于c51功能全的电子钟程序lcd1602程踊单倚颅莎初逐脉署轴暖丑云奶貉夏映威节坏澳镶丈屹晚怎科藻泛堤啊迎俱拌乘痞奇时酒瘴捧淌若滋虎效庙涪眠椒廓募柜捷玩娟捷元皇盼桃篓尚奇霓殊测彩可风帕卧嗓田荧挺碉聂扇舒毁川策梯俏恬龟漳硒临湘亚遮贫繁悬咸满膏慢绩呵莉新赢粹抓衷武堤次缕叔酬箭丢滤汇蒙爪铣饯搏租镊感拧绎闰袜悉宾注褂胃簿台述等皆瘟黄线扑撬弛丝鸿渡菠沂追音鲜禁顺懦允屋纯码纸妒膳婿武炯私荆捧椰篡昔诚款把兼迁绵城浩缮耕逊内充吹亮死呕粳座苑磊藤嗅宅晌冕理别祖图咯环刊鹅箔垒狞哦碰吓牺躯摇糟寡荡冠牙纪高怒残仇妒侯绩琢钠睦磕故怯撞栗档驭谁衍乍英淹燎乏阁词旋筹联埔聂凉鸡功能最全的电子钟【单片机】c51数字时钟(带年月日显示)摘要:本设计以单片机为核心,lcd1602显示。采用独立键盘输入能任意修改当前时间日期和设定闹钟时间。具有显示年月日(区分闰年和二月),闹钟报警和整点报时功能主程序:/* lcd1602电子钟 */# include # include lcd16024.hsbit key1 = P20;/调整sbit key2 = P21;/加1sbit key3 = P22;/减1sbit speaker = P23;/蜂鸣器sbit key4 = P24;/闹钟设计bit cal_year = 1;/进入判断闰年标志位bit leap_year;/闰年标志位bit calculate = 0;/日加一标记bit run = 0;/闹钟标志bit beep = 0;/整点报时标志/uint8 num = 0;/调整是给的脉冲uint8 code str1 = D: ;uint8 code str2 = T: ;uint8 code str3 = Wek;uint8 daystr=2013-07-29 ;/年月日格式uint8 timestr=21:30:59 N; /时分秒格式uint8 daystr1=2013-07-29 ;/闹钟年月日格式uint8 timestr1=21:30:59 N; /闹钟时分秒格式uint8 numweek = 0;/星期加1标记char week = 1;/星期char sec = 53;/秒char min = 50;/分char hour = 23;/时uint8 day = 30;/ 日uint8 month = 9;/月uint16 year = 2013;/年char week1 = 1;/闹钟星期 char sec1 = 58;/闹钟秒char min1 = 50;/闹钟分char hour1 = 23;/闹钟时uint8 day1 = 30;/闹钟日uint8 month1 = 9;/闹钟月uint16 year1 = 2013;/闹钟年uint8 WeekData1;/闹钟星期标记uint8 number = 0;/定时uint8 WeekData;/星期标记uint8 speaker_num; /整点报时次数uint8 scan_key(void);/函数声名 /* 更新LCD时间分离读取 */void TimeChange()/时分秒timestr7 = sec%10+0;timestr6 = sec/10+0;timestr4 = min%10+0;timestr3 = min/10+0;timestr1 = hour%10+0;timestr0 = hour/10+0;/年月日daystr9 = day%10+0;daystr8 = day/10+0;daystr6 = month%10+0;daystr5 = month/10+0;daystr3 = year%10+0;daystr2 = year/10%10+0;daystr1 = year/100%10+0;daystr0 = year/1000+0;/星期WeekData = week+0;/* 闹钟更新LCD时间分离读取 */void TimeChange1()/时分秒timestr17 = sec1%10+0;timestr16 = sec1/10+0;timestr14 = min1%10+0;timestr13 = min1/10+0;timestr11 = hour1%10+0;timestr10 = hour1/10+0;/年月日daystr19 = day1%10+0;daystr18 = day1/10+0;daystr16 = month1%10+0;daystr15 = month1/10+0;daystr13 = year1%10+0;daystr12 = year1/10%10+0;daystr11 = year1/100%10+0;daystr10 = year1/1000+0;/星期WeekData1 = week1+0;/* 初始化系统定时器0 */void systimer0_init(void)TMOD |=0x01;/设置为1时用或(|)TMOD &=0xfd;/设置为0时用与(&) TH0 = 0xDC; / 定时10ms TL0 = 0x00;EA = 1;ET0=1; TR0=1;EX0 = 1;/* 闹钟时间设置 */void naozhong()uint8 number = 1;uint8 a = 0;uint8 b = 0;if(0 = key4)Delay1Ms(5);if(0 = key4)a = 1;LCD_write_command(0xc0+9);LCD_write_command(0x0f);while(!key4);while(a)if(0 = key4)Delay1Ms(5);if(0 = key4)a = 0;run = run;while(!key4); if(run)timestr9 = Y;elsetimestr9 = N;if(0 = key1)Delay1Ms(5);if(0 = key1)b = 1;while(!key1);while(b) if(0 = key1)Delay1Ms(5);if(0 = key1)number+;if(4 = number)b = 0;while(!key1);if(number = 1)LCD_write_command(0xc0+9);LCD_write_command(0x0f);if(number = 2)LCD_write_command(0xc0+6);LCD_write_command(0x0f);if(number = 3)LCD_write_command(0xc0+3);LCD_write_command(0x0f); switch(number) case 1: if(0 = key2) /闹钟秒加1的设置 Delay1Ms(5);if(0 = key2) sec1+; if(60 = sec1)sec1 = 0;while(!key2);timestr17 = sec1%10+0;timestr16 = sec1/10+0;LCD_write_char(8,1,timestr16);LCD_write_char(9,1,timestr17);LCD_write_command(0xc0+9); if(0 = key3) /闹钟秒减1的设置 Delay1Ms(5);if(0 = key3) sec1-; if(sec1 0)sec1 = 59;while(!key3);timestr17 = sec1%10+0;timestr16 = sec1/10+0;LCD_write_char(8,1,timestr16);LCD_write_char(9,1,timestr17);LCD_write_command(0xc0+9); break;case 2: if(0 = key2) /闹钟分加1的设置 Delay1Ms(5);if(0 = key2) min1+; if(60 = min1)min1 = 0;while(!key2);timestr14 = min1%10+0;timestr13 = min1/10+0;LCD_write_char(5,1,timestr13);LCD_write_char(6,1,timestr14);LCD_write_command(0xc0+6); if(0 = key3) /闹钟分减1的设置 Delay1Ms(5);if(0 = key3) min1-; if(min1 0)min1 = 59;while(!key3);timestr14 = min1%10+0;timestr13 = min1/10+0;LCD_write_char(5,1,timestr13);LCD_write_char(6,1,timestr14);LCD_write_command(0xc0+6); break;case 3: if(0 = key2) /闹钟时加1的设置 Delay1Ms(5);if(0 = key2) hour1+; if(24 = hour1)hour1 = 0;while(!key2);timestr11 = hour1%10+0;timestr10 = hour1/10+0;LCD_write_char(2,1,timestr10);LCD_write_char(3,1,timestr11);LCD_write_command(0xc0+3); if(0 = key3) /闹钟时减1的设置 Delay1Ms(5);if(0 = key3) hour1-; if(hour1 0)hour1 = 23;while(!key3);timestr11 = hour1%10+0;timestr10 = hour1/10+0;LCD_write_char(2,1,timestr10);LCD_write_char(3,1,timestr11);LCD_write_command(0xc0+3); break;case 4:b = 0;LCD_write_command(0x0c);break;LCD_write_command(0x0c);while(!key4);/* 判断按键进入时间调整 */uint8 scan_key(void)uint8 number = 1;uint8 a = 0;if(0 = key1)Delay1Ms(5);if(0 = key1)while(!key1);a = 1;LCD_write_command(0xc0+9);LCD_write_command(0x0f);while(a) if(0 = key1)Delay1Ms(5);if(0 = key1)number+;while(!key1);TR0 = 0;if(number = 2)LCD_write_command(0xc0+6);LCD_write_command(0x0f);if(number = 3)LCD_write_command(0xc0+3);LCD_write_command(0x0f);if(number = 4)LCD_write_command(0x80+11);LCD_write_command(0x0f);if(number = 5)LCD_write_command(0x80+8);LCD_write_command(0x0f);if(number = 6)LCD_write_command(0x80+5);LCD_write_command(0x0f);if(number = 7)LCD_write_command(0xc0+14);LCD_write_command(0x0f);if(8 = number)LCD_write_command(0x0c);a = 0;number = 0; switch(number) case 1: if(0 = key2) /秒加1的设置 Delay1Ms(5);if(0 = key2)sec+; if(60 = sec)sec = 0;timestr7 = sec%10+0;timestr6 = sec/10+0;LCD_write_char(8,1,timestr6);LCD_write_char(9,1,timestr7);LCD_write_command(0xc0+9);while(!key2); if(0 = key3) /秒减1的设置 Delay1Ms(5);if(0 = key3) sec-; if(sec 0)sec = 59;timestr7 = sec%10+0;timestr6 = sec/10+0;LCD_write_char(8,1,timestr6);LCD_write_char(9,1,timestr7);LCD_write_command(0xc0+9);while(!key3); break;case 2: if(0 = key2) /分加1的设置 Delay1Ms(5);if(0 = key2) min+; if(60 = min)min = 0;timestr4 = min%10+0;timestr3 = min/10+0;LCD_write_char(5,1,timestr3);LCD_write_char(6,1,timestr4);LCD_write_command(0xc0+6);while(!key2); if(0 = key3) /分减1的设置 Delay1Ms(5);if(0 = key3) min-; if(min 0)min = 59;timestr4 = min%10+0;timestr3 = min/10+0;LCD_write_char(5,1,timestr3);LCD_write_char(6,1,timestr4);LCD_write_command(0xc0+6);while(!key3); break;case 3: if(0 = key2) /时加1的设置 Delay1Ms(5);if(0 = key2) hour+;while(!key2); if(24 = hour)hour = 0;timestr1 = hour%10+0;timestr0 = hour/10+0;LCD_write_char(2,1,timestr0);LCD_write_char(3,1,timestr1);LCD_write_command(0xc0+3); if(0 = key3) /时减1的设置 Delay1Ms(5);if(0 = key3)while(!key3); hour-; if(hour 31)day=1; if(month=4|month=6|month=9|month=11) day+; if(day 30)day=1; if(month = 2) cal_year = 1;while(cal_year = 1) leap_year = (year % 4 = 0 & year % 100 != 0)|(year % 400 = 0);cal_year = 0;if(leap_year=1) day+;if(day 30)day=1; else day+;if(day 29)day=1;calculate = 0;daystr9 = day%10+0;daystr8 = day/10+0;LCD_write_char(10,0,daystr8);LCD_write_char(11,0,daystr9);LCD_write_command(0x80+11); if(0 = key3) /日减1的设置 Delay1Ms(5);if(0 = key3)while(!key3);calculate = 1; if(calculate = 1)if(month=1|month=3|month=5|month=7|month=8|month=10|month=12)day-;if(day = 0)day=31; if(month=4|month=6|month=9|month=11) day-; if(day = 0)day=30; if(month = 2) cal_year = 1;while(cal_year = 1) leap_year = (year % 4 = 0 & year % 100 != 0)|(year % 400 = 0);cal_year = 0;if(leap_year=1) day-;if(day = 0)day=30; else day-;if(day = 0)day=29;calculate = 0;daystr9 = day%10+0;daystr8 = day/10+0;LCD_write_char(10,0,daystr8);LCD_write_char(11,0,daystr9);LCD_write_command(0x80+11); break;case 5: if(0 = key2) /月加1的设置 Delay1Ms(5);if(0 = key2)while(!key2); month+; if(13 = month)month = 1;daystr6 = month%10+0;daystr5 = month/10+0;LCD_write_char(7,0,daystr5);LCD_write_char(8,0,daystr6);LCD_write_command(0x80+8); if(0 = key3) /月减1的设置 Delay1Ms(5);if(0 = key3)while(!key3); month-; if(month = 0)month = 12;daystr6 = month%10+0;daystr5 = month/10+0;LCD_write_char(7,0,daystr5);LCD_write_char(8,0,daystr6);LCD_write_command(0x80+8); break;case 6: if(0 = key2) /年加1的设置 Delay1Ms(5);if(0 = key2)while(!key2); year+; daystr3 = year%10+0;daystr2 = year/10%10+0;daystr1 = year/100%10+0;daystr0 = year/1000+0;LCD_write_char(2,0,daystr0);LCD_write_char(3,0,daystr1);LCD_write_char(4,0,daystr2);LCD_write_char(5,0,daystr3);LCD_write_command(0x80+5);if (0 = key3) /年减1的设置 Delay1Ms(5);if(0 = key3)while(!key3); year-; if(year = 0)year = 2020;daystr3 = year%10+0;daystr2 = year/10%10+0;daystr1 = year/100%10+0;daystr0 = year/1000+0;LCD_write_char(2,0,daystr0);LCD_write_char(3,0,daystr1);LCD_write_char(4,0,daystr2);LCD_write_char(5,0,daystr3);LCD_write_command(0x80+5); break;case 7: if(0 = key2) /星期加1的设置 Delay1Ms(5);if(0 = key2)while(!key2); week+; if(7 = week)week = 0;LCD_write_char(14,1,week+0);LCD_write_command(0xc0+14); if (0 = key3) /星期减1的设置 Delay1Ms(5);if
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 邮储银行2025海西蒙古族藏族自治州秋招结构化面试经典题及参考答案
- 建设银行2025神农架林区秋招笔试综合模拟题库及答案
- 邮储银行2025毕节市金融科技岗笔试题及答案
- 交通银行2025秋招无领导小组面试案例库浙江地区
- 中国银行2025延边朝鲜族自治州半结构化面试15问及话术
- 农业银行2025大庆市秋招笔试综合模拟题库及答案
- 交通银行2025抚州市秋招结构化面试经典题及参考答案
- 建设银行2025阿里市秋招笔试创新题型专练及答案
- 邮储银行2025漳州市结构化面试15问及话术
- 中国银行2025南宁市小语种岗笔试题及答案
- 血友病课件完整版
- 神经系统的分级调节课件 【知识精讲+备课精研+高效课堂】 高二上学期生物人教版选择性必修1
- 三年级上册数学试卷-第一单元 混合运算 北师大版 (含答案)
- 临床职业素养
- 种子学-种子的化学成分课件
- 教学课件-英语学术论文写作(第二版)
- 手术室无菌技术 课件
- ISO 31000-2018 风险管理标准-中文版
- 六年级数学上册教案6:分数乘法:分数乘小数-人教版
- 小学综合实践六年级上册第1单元《考察探究》教材分析及全部教案
- 教育评价学全套ppt课件完整版教学教程
评论
0/150
提交评论