课程设计-基于单片机的自动打铃系统设计内容摘要:

if(s1==0) //功能键按下 { while(s1==0)。 //松手检测 s1num++。 //功能键按下计数 TR0=0。 //T0 定时停止,进入时间调整 switch(s1num) { case 1: write_(0x80+0x40+0x09)。 break。 //光标闪烁位定为秒个位 case 2: write_(0x80+0x40+0x06)。 break。 //光标闪烁位定为分个位 case 3: write_(0x80+0x40+0x03)。 break。 //光标闪烁位定为时个位 case 4: write_(0x80+0x0b)。 break。 //光标闪烁位定为日个位 case 5: write_(0x80+0x08)。 break。 //光标闪烁位定为月个位 case 6: write_(0x80+0x05)。 break。 //光标闪烁位定为年个位 } write_(0x0f)。 //光标闪烁 if(s1num==7) { s1num=0。 //按键计数复位 16 write_(0x0c)。 //光标停止闪烁 TR0=1。 //重新启动定时器 } } } if(s2==0) //S2 键 时分秒 +1 模块 { delay(5)。 if(s2==0) { while(s2==0)。 switch(s1num) { case 1: second++。 //秒 + if(second==60) second=0。 //复位 write_hms(8,second)。 //秒输出显示 write_(0x80+0x40+0x09)。 //光标闪烁位定为秒个位 break。 case 2: minute++。 if(minute==60) minute=0。 //复位 write_hms(5,minute)。 //分输出显示 write_(0x80+0x40+0x06)。 //光标闪烁位定为分个位 break。 case 3: hour++。 if(hour==24) hour=0。 //复位 write_hms(2,hour)。 //时输出显示 write_(0x80+0x40+0x03)。 //光标闪烁位定为时个位 break。 case 4: date++。 //日 + if(year%4==0) //平闰年判断 { if(date==month1[month1]+1) { date=1。 } } else { if(date==month0[month1]+1) { date=1。 } } 17 write_ymd(10,date)。 //日输出显示 write_(0x80+0x0b)。 //光标闪烁位定为日个位 break。 case 5: month++。 //月 + if(month==13) month=1。 if(year%4==0) //判断日和月的配对关系 { if(datemonth1[month1]) date=month1[month1]。 } else { if(datemonth0[month1]) date=month0[month1]。 } write_ymd(10,date)。 //日输出显示 write_ymd(7,month)。 //月输出显示 write_(0x80+0x08)。 //光标闪烁位定为月个位 break。 case 6: year++。 //年 + if(year==100) year=1。 //复位 write_ymd(4,year)。 //年输 出显示 write_(0x80+0x05)。 //光标闪烁位定为年个位 break。 } } } if(s3==0) //时分秒 1 模块 { delay(5)。 if(s3==0) { while(s3==0)。 switch(s1num) { case 1: second。 //秒 if(second==255) second=59。 //复位 write_hms(8,second)。 //秒输出显示 write_(0x80+0x40+0x09)。 //光标闪烁位定为秒个位 break。 case 2: minute。 if(minute==255) minute=59。 //复位 write_hms(5,minute)。 //分输出显示 write_(0x80+0x40+0x06)。 //光标闪烁位定为分个位 break。 18 case 3: hour。 if(hour==255) hour=23。 //复位 write_hms(2,hour)。 //时输出显示 write_(0x80+0x40+0x03)。 //光标闪烁位定为时个位 break。 case 4: date。 //日 if(year%4==0) { if(date==0) { date=month1[month1]。 } } else { if(date==0) { date=month0[month1]。 } } write_ymd(10,date)。 //日输出显示 write_(0x80+0x0b)。 //光标闪烁位定为日个位 break。 case 5: month。 //月 if(month==0) month=12。 if(year%4==0) //判断日和月的配对关系 { if(datemonth1[month1]) date=month1[month1]。 } else { if(datemonth0[month1]) date=month0[month1]。 } write_ymd(10,date)。 //日输出显示 write_ymd(7,month)。 //月输出显示 write_(0x80+0x08)。 //光标闪烁位定为月个位 break。 case 6: year。 //年 if(year==0) year=99。 //复位 write_ymd(4,year)。 //年输出显示 write_(0x80+0x05)。 //光标闪烁位定为年个位 break。 } } 19 } } void initialize() //LCD 初始化函数 { uchar num。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。