欢迎来到天天文库
浏览记录
ID:48386177
大小:67.00 KB
页数:16页
时间:2019-08-03
《Ds18b20测温ds1302时钟led1602显示模块化编程.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、战龙啸野QQ1159551878/*Ds18b20测温+ds1302时钟+led1602显示模块化编程一个。C文件与一个。H文件相对应。一共有9个文件main.cds18b20.hds18b20.cds1302.hds1302.clcd1602.hlcd1602.cdelay.hdelay.c*///main.c#include#include"ds18b20.h"#include"ds1302.h"#include"lcd1602.h"ucharsecond,minute,hour,day,month,year,count=0;ucharReadValue,num
2、,time;//按键sbitmenu=P1^5;//菜单sbitadd=P1^6;//加一sbitdec=P1^7;//减一voidDisplaySecond(ucharx){uchari,j;i=x/10;j=x%10;write_1602com(0xc7);write_1602dat(0x30+i);write_1602dat(0x30+j);}voidDisplayMinute(ucharx){uchari,j;i=x/10;j=x%10;write_1602com(0xc4);write_1602dat(0x30+i);write_1602dat(0x30+j);}16战龙啸野Q
3、Q1159551878voidDisplayHour(ucharx){uchari,j;i=x/10;j=x%10;write_1602com(0xc1);write_1602dat(0x30+i);write_1602dat(0x30+j);}voidDisplayDay(ucharx){uchari,j;i=x/10;j=x%10;write_1602com(0x89);write_1602dat(0x30+i);write_1602dat(0x30+j);}voidDisplayMonth(ucharx){uchari,j;i=x/10;j=x%10;write_1602com(0
4、x86);write_1602dat(0x30+i);write_1602dat(0x30+j);}voidDisplayYear(ucharx){uchari,j;i=x/10;j=x%10;write_1602com(0x83);write_1602dat(0x30+i);write_1602dat(0x30+j);}voidread_date(void){ReadValue=ReadSet1302(0x81);16战龙啸野QQ1159551878second=((ReadValue&0x70)>>4)*10+(ReadValue&0x0F);ReadValue=ReadSet130
5、2(0x83);minute=((ReadValue&0x70)>>4)*10+(ReadValue&0x0F);ReadValue=ReadSet1302(0x85);hour=((ReadValue&0x70)>>4)*10+(ReadValue&0x0F);ReadValue=ReadSet1302(0x87);day=((ReadValue&0x70)>>4)*10+(ReadValue&0x0F);ReadValue=ReadSet1302(0x89);month=((ReadValue&0x70)>>4)*10+(ReadValue&0x0F);ReadValue=ReadS
6、et1302(0x8d);year=((ReadValue&0x70)>>4)*10+(ReadValue&0x0F);DisplaySecond(second);DisplayMinute(minute);DisplayHour(hour);DisplayDay(day);DisplayMonth(month);DisplayYear(year);}voidturn_val(charnewval,ucharflag,ucharnewaddr,uchars1num){newval=ReadSet1302(newaddr);//读取当前时间newval=((newval&0x70)>>4)
7、*10+(newval&0x0f);//将bcd码转换成十进制if(flag)//判断是加一还是减一{newval++;switch(s1num){case1:if(newval>99)newval=0;DisplayYear(newval);break;case2:if(newval>12)newval=1;DisplayMonth(newval);break;case3:if(newval>31)newval=1;Display
此文档下载收益归作者所有