DS1302芯片+1602液晶顯示 作者: 時(shí)間:2016-11-29 來(lái)源:網(wǎng)絡(luò) 加入技術(shù)交流群 掃碼加入和技術(shù)大咖面對(duì)面交流海量資料庫(kù)查詢 收藏 /*****************讀出秒的十進(jìn)制數(shù)***************************/uchar readsecond(uchar dat){dat=read_1302add(0x81);second=((dat&0x70)>>4)*10+(dat&0x0f);return second;}/*****************讀出分的十進(jìn)制數(shù)***************************/uchar readminute(uchar dat){dat=read_1302add(0x83);minute=((dat&0x70)>>4)*10+(dat&0x0f);return minute;}/*****************讀出小時(shí)的十進(jìn)制數(shù)***************************/uchar readhour(uchar dat){dat=read_1302add(0x85);hour=((dat&0x70)>>4)*10+(dat&0x0f);return hour;}/*****************讀出天的十進(jìn)制數(shù)***************************/uchar readday(uchar dat){dat=read_1302add(0x87);day=((dat&0x70)>>4)*10+(dat&0x0f);return day;}/*****************讀出月的十進(jìn)制數(shù)***************************/uchar readmonth(uchar dat){dat=read_1302add(0x89);month=((dat&0x70)>>4)*10+(dat&0x0f);return month;}/*****************讀出周的十進(jìn)制數(shù)***************************/uchar readweek(uchar dat){dat=read_1302add(0x8b);week=((dat&0x70)>>4)*10+(dat&0x0f);return week;}/*****************讀出年的十進(jìn)制數(shù)***************************/uchar readyear(uchar dat){dat=read_1302add(0x8d);year=((dat&0xf0)>>4)*10+(dat&0x0f);return year;}/************************讀出所有時(shí)間**********************/readtime(){readsecond();readminute();readhour();readday();-readmonth();readweek();readyear();}/*********************向1602寫(xiě)入時(shí)間****************************/void write_second(){uchar shi,ge;shi=second/10;ge=second%10;Write1602(0x80+0x40+9,0x30+shi);Write1602(0x80+0x40+10,0x30+ge);}void write_minute(){uchar shi,ge;shi=minute/10;ge=minute%10;Write1602(0x80+0x40+6,0x30+shi);Write1602(0x80+0x40+7,0x30+ge);}void write_hour(){uchar shi,ge;shi=hour/10;ge=hour%10;Write1602(0x80+0x40+3,0x30+shi);Write1602(0x80+0x40+4,0x30+ge);}void write_day(){uchar shi,ge;shi=day/10;ge=day%10;Write1602(0x80+8,0x30+shi);Write1602(0x80+9,0x30+ge);}void write_month(){uchar shi,ge;shi=month/10;ge=month%10;Write1602(0x80+5,0x30+shi);Write1602(0x80+6,0x30+ge);}void write_year(){uchar shi,ge;shi=year/10;ge=year%10;Write1602(0x80+2,0x30+shi);Write1602(0x80+3,0x30+ge);}void write_week(){/*uchar shi,ge;shi=week/10;ge=week%10;Write1602(0x80+12,0x30+shi);Write1602(0x80+13,0x30+ge);*/Write1602(0x80+12,0x30+week);}void main(){delay(100);init1602();init_1302();while(1){readtime();write_second();write_minute();write_hour();write_day();write_month();write_year();write_week();}} 上一頁(yè) 1 2 下一頁(yè)
評(píng)論