<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)驅(qū)動(dòng)DS1302時(shí)間DS18B20溫度12864液晶顯示完整程序設(shè)計(jì)

          單片機(jī)驅(qū)動(dòng)DS1302時(shí)間DS18B20溫度12864液晶顯示完整程序設(shè)計(jì)

          作者: 時(shí)間:2012-12-11 來源:網(wǎng)絡(luò) 收藏

          time_lcd(){
          unsigned char y,k,time,add,i,we1,we2;
          add=128;///////必須是小于64-8大于64
          d12864_lcd(0,0,12);//: 北
          d12864_lcd(16,0,13);//: 京
          d12864_lcd(31,0,14);//: 時(shí)
          d12864_lcd(47,0,15);//: 間
          k=0x81;
          y=0; //在第幾行顯示
          for(i=0;i3;i++){
          time=r_1302(k);
          time1[i]=time;
          add=add-8;;
          time=time0x0f;
          d12864_lcd(add,y,time);///秒個(gè)位
          add=add-8;
          time=r_1302(k);
          time=0xf0;
          time>>=4;
          d12864_lcd(add,y,time);//秒十位
          add=add-8;;
          k+=2;
          }
          d12864_lcd(40+64,y,10);//:
          d12864_lcd(16+64,y,10);//: 顯示兩點(diǎn)
          //
          time1[5]=r_1302(0x8b);
          d12864_lcd(64,4,16);//: 星
          d12864_lcd(64+16,4,17);//: 期
          r_1302(0x8b);//讀星期
          d12864_lcd(64+32,4,r_1302(0x8b));//: 讀星期幾`并顯示
          ////
          y=2;//在第四行顯示
          add=56+16;
          time=r_1302(0x87);
          time1[3]=time;
          d12864_lcd(add,y,time0x0f);//: 顯示日
          time=r_1302(0x87);
          time=0xf0;
          time>>=4;
          add-=8;
          d12864_lcd(add,y,time); //顯示日的十位
          add-=8;
          add-=8;
          time1[4]=time=r_1302(0x89);
          d12864_lcd(add,y,time0x0f);//: 顯示月
          time=r_1302(0x89);
          time=0xf0;
          time>>=4;
          add-=8;
          d12864_lcd(add,y,time); //顯示月的十位
          add-=8;
          add-=8;
          time1[6]=time=r_1302(0x8d);
          d12864_lcd(add,y,time0x0f);//: 顯示年
          time=r_1302(0x8d);
          time=0xf0;
          time>>=4;
          add-=8;
          d12864_lcd(add,y,time); //顯示年的十位
          //////讀完

          d12864_lcd(40+16,y,11);//:
          d12864_lcd(16+16,y,11);//: 顯示兩/
          add-=8;
          d12864_lcd(add,y,0);//: 0
          add-=8;
          d12864_lcd(add,y,2);//: 2

          d12864_lcd(0,4,18);//: 溫
          d12864_lcd(16,4,19);//: 度
          we1=wendu();
          we2=we1/10;
          d12864_lcd(32,4,we2);//: 2
          we2=we1-we2*10;
          d12864_lcd(40,4,we2);//: 顯示溫度值
          cs1_lcd();
          y_lcd(4);
          x_lcd(50);
          w_lcd(0x18);
          x_lcd(51);
          w_lcd(0x18);
          }
          /////////////////////////顯示時(shí)間完畢


          hei_lcd(unsigned char x,y){ //全黑用來做閃標(biāo)用
          char iy,ix,di,i;
          di=0x00;
          if(x>63){
          x=x-64;
          cs2_lcd();
          }
          else cs1_lcd();
          i=0;
          for(iy=0;iy2;iy++){
          for(ix=0;ix16;ix++){
          y_lcd(iy+y);
          x_lcd(ix+x);
          w_lcd(di);
          }
          }
          }
          key_t(){ //鍵盤key1 加1 key2 減1

          if(!key1){
          key_time++;
          delay1(20000);
          while(!key1);
          }
          if(!key2){
          key_time--;
          delay1(20000);
          while(!key2);
          }
          }


          void delay11(word useconds)
          {
          for(;useconds>0;useconds--)
          key_t();
          }

          time_key(){
          unsigned char keyd,ktime;
          unsigned int year;
          word kk;
          keyd=0;
          kk=10000;///閃動(dòng)快慢
          if(!key0){
          for(;;){
          if(!key0){
          keyd=keyd+1;
          delay1(500);
          if(keyd>8)keyd=1;
          key_time=0;//////每設(shè)牟換一個(gè)就把存設(shè)時(shí)間清0
          key0=1;
          while(!key0);
          key0=1;
          }
          ////////////////////////閃程序
          if(keyd==1){//=1進(jìn)入秒閃 同時(shí)設(shè)置秒時(shí)間
          key_time=(time1[0]0x0f)+((time1[0]0xf0)>>4)*10; //將數(shù)姐里的數(shù)度到key_time里 10進(jìn)制
          hei_lcd(112,0);//x y
          delay11(kk);//////閃動(dòng)快慢
          if(key_time>=60)key_time=0;
          d12864_lcd(112,0,key_time/10);
          d12864_lcd(120,0,key_time-(key_time/10)*10);
          time1[0]=(((key_time/10)4)0xf0)+(key_time-(key_time/10)*10); //換成BCD碼存到數(shù)組里
          delay1(10000);
          }
          if(keyd==2){//=1進(jìn)入分閃 同時(shí)設(shè)置秒時(shí)間
          key_time=(time1[1]0x0f)+((time1[1]0xf0)>>4)*10; //將數(shù)姐里的數(shù)度到key_time里 10進(jìn)制
          hei_lcd(88,0);//x y
          delay11(kk);//////閃動(dòng)快慢
          if(key_time>=60)key_time=0;
          d12864_lcd(88,0,key_time/10);
          d12864_lcd(96,0,key_time-(key_time/10)*10);
          delay1(10000);
          time1[1]=(((key_time/10)4)0xf0)+(key_time-(key_time/10)*10); //換成BCD碼存到數(shù)組里
          }
          if(keyd==3){//=1進(jìn)入時(shí)閃 同時(shí)設(shè)置秒時(shí)間
          key_time=(time1[2]0x0f)+((time1[2]0xf0)>>4)*10; //將數(shù)姐里的數(shù)度到key_time里 10進(jìn)制
          hei_lcd(64,0);//x y
          delay11(kk);//////閃動(dòng)快慢
          if(key_time>=24)key_time=0;
          d12864_lcd(64,0,key_time/10);
          d12864_lcd(72,0,key_time-(key_time/10)*10);
          time1[2]=(key_time/10)4+(key_time-key_time/10);
          delay1(10000);
          time1[2]=(((key_time/10)4)0xf0)+(key_time-(key_time/10)*10); //換成BCD碼存到數(shù)組里
          }
          if(keyd==4){//=1進(jìn)入年閃 同時(shí)設(shè)置秒時(shí)間
          key_time=(time1[6]0x0f)+((time1[6]0xf0)>>4)*10; //將數(shù)姐里的數(shù)度到key_time里 10進(jìn)制
          hei_lcd(16,2);//x y
          delay11(kk);//////閃動(dòng)快慢
          if(key_time>99)key_time=0;
          d12864_lcd(16,2,key_time/10);
          d12864_lcd(24,2,key_time-(key_time/10)*10);
          time1[6]=(key_time/10)4+(key_time-key_time/10);
          delay1(10000);
          time1[6]=(((key_time/10)4)0xf0)+(key_time-(key_time/10)*10); //換成BCD碼存到數(shù)組里
          }

          if(keyd==5){//=1進(jìn)入月閃 同時(shí)設(shè)置秒時(shí)間
          key_time=(time1[4]0x0f)+((time1[4]0xf0)>>4)*10; //將數(shù)姐里的數(shù)度到key_time里 10進(jìn)制
          hei_lcd(40,2);//x y
          delay11(kk);//////閃動(dòng)快慢
          if(key_time>=13)key_time=0;
          d12864_lcd(40,2,key_time/10);
          d12864_lcd(48,2,key_time-(key_time/10)*10);
          time1[4]=(key_time/10)4+(key_time-key_time/10);
          delay1(10000);
          time1[4]=(((key_time/10)4)0xf0)+(key_time-(key_time/10)*10); //換成BCD碼存到數(shù)組里
          }

          if(keyd==6){//=1進(jìn)入日閃 同時(shí)設(shè)置秒時(shí)間
          key_time=(time1[3]0x0f)+((time1[3]0xf0)>>4)*10; //將數(shù)姐里的數(shù)度到key_time里 10進(jìn)制
          year=(time1[4]0x0f)+(((time1[4]0xf0)>>4)*10)+2000;
          switch(time1[4]){ //計(jì)算閏月
          case 1: ktime=31;break;
          case 3: ktime=31;break;
          case 5: ktime=31;break;
          case 7: ktime=31;break;
          case 8: ktime=31;break;
          case 10: ktime=31;break;
          case 12: ktime=31;break;
          case 4: ktime=30;break;
          case 6: ktime=30;break;
          case 9: ktime=30;break;
          case 11: ktime=30;break;
          case 2: if(year%4==0year%100!=0||year%400==0) ktime=29;
          else ktime=29;break;
          }
          hei_lcd(64,2);//x y
          delay11(kk);//////閃動(dòng)快慢
          if(key_time>ktime)key_time=0;
          d12864_lcd(64,2,key_time/10);
          d12864_lcd(72,2,key_time-(key_time/10)*10);
          time1[3]=(key_time/10)4+(key_time-key_time/10);
          delay1(10000);
          time1[3]=(((key_time/10)4)0xf0)+(key_time-(key_time/10)*10); //換成BCD碼存到數(shù)組里
          }

          if(keyd==7){//=1進(jìn)入星期閃 同時(shí)設(shè)置秒時(shí)
          char iy,ix,di,i;
          key_time=time1[5];
          di=0x00;
          cs2_lcd();
          i=0;
          for(iy=0;iy2;iy++){
          for(ix=0;ix8;ix++){
          y_lcd(iy+4);
          x_lcd(ix+96);
          w_lcd(di);
          }
          di=00;
          }
          delay11(kk);//////閃動(dòng)快慢
          if(key_time>7)key_time=0;
          d12864_lcd(96,4,key_time);
          time1[5]=key_time;
          delay1(10000);
          time1[5]=key_time; //換成BCD碼存到數(shù)組里
          }
          ////////////////////
          if(!key3)break;
          }
          ds1302_c(); ///更改時(shí)間
          }
          }

          ///////////////
          lcd_key(){
          if(!key3){
          if(!key2)lcd_d=1;
          else lcd_d=0;
          }
          }
          main(){
          ds1302_c();
          clr_lcd();
          for(;;){
          time_lcd();
          time_key();
          lcd_key();
          }
          }

          51單片機(jī)相關(guān)文章:51單片機(jī)教程


          單片機(jī)相關(guān)文章:單片機(jī)教程


          單片機(jī)相關(guān)文章:單片機(jī)視頻教程


          單片機(jī)相關(guān)文章:單片機(jī)工作原理



          上一頁 1 2 3 下一頁

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();