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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 單片機電子時鐘程序

          單片機電子時鐘程序

          作者: 時間:2016-11-29 來源:網(wǎng)絡 收藏
          /*****************************************************
          數(shù)碼驅(qū)動部分
          *****************************************************/
          void delay(unsigned char z)
          {
          unsigned char x,y;
          for(x=0;x {y = 100;
          while(--y);}
          }
          /****************************************************
          595 驅(qū)動
          ****************************************************/
          void _74hc595(unsigned char dat)
          {
          unsigned char n;
          sh=0;
          st=0;
          for(n=0;n<8;n++)
          {
          if(dat&0x80)ds=1;
          else ds=0;
          sh=1;
          dat<<=1;
          sh=0;
          }
          st=1;
          }
          /******************************************************
          掃描部分
          ******************************************************/
          void sanf_display(void)
          {
          static unsigned char n;
          unsigned char scanf_dat_temp[4];
          if((menu_button2_down ==1)&&(time.mode==0))
          {
          if(button2_length_whack_flag)
          {
          Alarm_on_off = ~Alarm_on_off;
          button2_length_whack_flag = 0;
          time.delaycount = Alarm_switch_on_off_ms;
          }
          scanf_dat[0] = time.AlarmHou;
          scanf_dat[1] = time.AlarmMin;
          // Alarm_on_off_display = 1;
          }
          // else Alarm_on_off_display = 0;
          if((menu_button3_down ==1)&&(time.mode==0))
          {
          scanf_dat[0] = time.mon;
          scanf_dat[1] = time.day;
          }
          scanf_dat_temp[0] = P_leab_led_7[scanf_dat[0]/10];
          scanf_dat_temp[1] = P_leab_led_7[scanf_dat[0]%10];
          scanf_dat_temp[2] = P_leab_led_7[scanf_dat[1]/10];
          scanf_dat_temp[3] = P_leab_led_7[scanf_dat[1]%10];
          // if(Alarm_on_off_display)
          // {
          if(Alarm_on_off)
          {
          //scanf_dat_temp[0] &= 0x7f;
          //scanf_dat_temp[1] &= 0x7f;
          //scanf_dat_temp[2] &= 0x7f;
          scanf_dat_temp[3] &= 0xf7;
          // }
          }
          if(time.count>=50&&time.mode==0&&menu_button3_down ==0&&menu_button2_down ==0)scanf_dat_temp[1] &= 0xf7;
          if(menu_button2_down||menu_button3_down) flash_control = 0;
          if(flash_control)
          {
          if(time.mode&0x01){scanf_dat_temp[0] = 0xff; scanf_dat_temp[1] = 0xff;}
          else {scanf_dat_temp[2] = 0xff; scanf_dat_temp[3] = 0xff;}
          }
          for(n=0 ;n<4;n++)
          {
          _74hc595( scanf_dat_temp[n]);
          switch(n)
          {
          case 0:led0=1;led1=0; led2=0; led3=0;break;
          case 1:led0=0;led1=1; led2=0; led3=0;break;
          case 2:led0=0;led1=0; led2=1; led3=0;break;
          case 3:led0=0;led1=0; led2=0; led3=1;break;
          default :led0=0;led1=0; led2=0; led3=0;break;
          }
          delay(5);
          _74hc595(0xff);
          led0 = 0; led1 = 0; led2 = 0; led3 = 0;
          delay(1);
          }
          }
          /**********************************************************
          加載顯存
          **********************************************************/
          void proces_start(void)
          {
          unsigned char temp[6];
          unsigned int dattemp;
          if(time.mode==0) //時間顯示
          {
          scanf_dat[0] = time.hou;
          scanf_dat[1] = time.min;
          }
          else if(time.mode==1)//秒表顯示
          {
          if(time.stopwatch[2]>0)
          {
          scanf_dat[0] = time.stopwatch[2];
          scanf_dat[1] = time.stopwatch[1];
          }
          else
          {
          scanf_dat[0] = time.stopwatch[1];
          scanf_dat[1] = time.stopwatch[0];
          }
          }
          else if(time.mode<4)//
          {
          scanf_dat[0] = time.hou;
          scanf_dat[1] = time.min;
          }
          else if(time.mode<6)
          {
          scanf_dat[0] = time.mon;
          scanf_dat[1] = time.day;
          }
          else if(time.mode<8)
          {
          scanf_dat[0] = time.year[1];
          scanf_dat[1] = time.year[0];
          }
          else if(time.mode<10)
          {
          scanf_dat[0] = time.AlarmHou;
          scanf_dat[1] = time.AlarmMin;
          }
          else
          {
          dattemp = time.cymometer[1];
          dattemp = dattemp<<8;
          dattemp+=time.cymometer[0];
          temp[1] = dattemp%10000/100;
          temp[0] = dattemp%100;
          scanf_dat[0] = temp[1];
          scanf_dat[1] = temp[0];
          }
          if((time.AlarmHou==time.hou)&&(time.AlarmMin==time.min)&&(Alarm_on_off==1))
          {
          buzzer = 1;
          }
          else buzzer=0;
          }
          /*****************************************************************************
          系統(tǒng)初始化
          *****************************************************************************/
          void syster_init(void)
          {
          time.sec = 0;
          time.min = 59;
          time.hou = 23;
          time.day = 28;
          time.mon = 2;
          time.year[0] = 13;
          time.year[1] = 20;
          time.AlarmHou = 6;
          time.AlarmMin = 30;
          time.mode = 0;
          time.stopwatch[0]=0;
          time.stopwatch[1]=0;
          time.stopwatch[2]=0;
          Time_Count0_Init();
          }
          main()
          {
          syster_init();
          while(1)
          {
          button3_proces();
          button2_proces();
          proces_start();
          sanf_display();
          }
          }
          下面為hex文件內(nèi)容:1007CB0012070E1207B712078A1202E812000E80E8
          :0107DB00F22B
          :10073400000A00FA004C006800B800290009007A99
          :10074400000800281F1D1F1E1F1E1F1F1E1F1E1F07
          :10077300758951758CD8758AF0D2A9D28CD288D25A
          :07078300A8758B05D2AF221F
          :10039A00E53524FEB4080040030204479003B4750F
          :1003AA00F003A4C58325F0C583730203CC0203D9E5
          :1003BA000203E602040702041402042102042E02C4
          :1003CA00043B0526E526D3943B4072E4F526220534
          :1003DA0027E527D394174065E4F527220528E52960
          :1003EA00B40209E528D395384002800DE529900723
          :1003FA004793FFE528D39F4044752801220529E544
          :10040A0029D3943B4037E4F52922052AE52AD394D7
          :10041A0063402AE4F52A22052BE52AD39463401D7A
          :10042A00E4F52B22052CE52CD3943B4010E4F52C63
          :0E043A0022052DE52DD3943B4003E4F52D2241
          :10044800E53524FEB4080040030204F59004627503
          :10045800F003A4C58325F0C5837302047A020488D7
          :100468000204960204B10204BE0204CC0204DA02B9
          :1004780004E8E526D39400400315262275263B227E
          :10048800E527D3940040031527227527172215283E
          :10049800E528C394015056E529B40204853828227A
          :1004A800E52990074793F528221529E529C39401E2
          :1004B800503B75290C22E52AD394004003152A22C3
          :1004C800752A6322E52AD394004003152B22752B45
          :1004D8006322E52CD394004003152C22752C3B2273
          :0E04E800E52DD394004003152D22752D17220B
          :03000B0002017F70
          :0D017F00C0E0C0F0C083C082C0D075D008C1
          :10018C00758CD8758AF0B2B7AF2B7E007C007D647D
          :10019C001206A7E52A2FFFEC3EEF540360057538D5
          :1001AC001C800375381D12062B1204F61205A3E5EC
          :1001BC003564017037AF39EFC4131313540130E0B9
          :1001CC002BAF21EF54FBF521052EE52EC394644093
          :1001DC0005752E00052FE52FC3943C4005752F00A7
          :1001EC000530E530C3943C4003753000AF21EF136C
          :1001FC0013543F30E009752E00752F00753000AF99
          :10020C0021EFC4540F30E008D28E858D32858B31AE
          :10021C00AF21EFC413540730E016D28ED53311C280
          :10022C008E858D32858B31753364758B00758D00A1
          :10023C00E535D39401402CE535940A50260534E578
          :10024C003494284025753400AF39EF13131354013F
          :10025C00F4540133333354F8FFAE39EE54F74FF501
          :10026C00398007AF39EF54F7F5390524E524C394E9
          :10027C006440057524000525E525C3943C400575AF
          :10028C0025000526E526C3943C4005752600052768
          :10029C00E527D3941740057527000528E529B402F6
          :1002AC0009E528D395384014800DE529900747932C
          :1002BC00FFE528D39F40057528010529E529D3942E
          :1002CC000C4005752901052AE52AD39463400205E3
          :0102DC002BF6
          :0B02DD00D0D0D082D083D0F0D0E0322F
          :030003000207A150
          :1007A100C0E0C0D075D018753764AF39EF4402F599
          :0607B10039D0D0D0E03287
          :10062B00AF39EF30E01B20B20BD53615E4F536753C
          :10063B0035028006E4F536753501AF39EF54FEF51A
          :10064B0039AF39EFC31330E0521537E537646270B9
          :10065B004A20B247E535700CAF39EF4401F53975D7
          :10066B0036648029E535B40105E4F535801FE535A1
          :10067B00C3940A500E0535E4F534AF39EF54FEF54B
          :10068B0039800AE4F535AF39EF54FBF539AF39EF63
          :0C069B0054EFF539AF39EF54FDF539226A
          :10078A00AF39EFC4540F20E00D20B30AAF39EF445C
          :07079A0010F53975366422E9
          :1004F600AF39EFC4540F30E07620B3621536E536D7
          :100506006462704AE535B4011BAF39EFC4131313A7
          :100516005401F45401C43333335480FFAE39EE54DE
          :100526007F4FF539E535640A7021AF21EFC45401D8
          :10053600F45401C454F0FFAE21EE54EF4FF521E41C
          :10054600F58BF58DAF21EF54DFF52112039AE536D1
          :10055600701D75360AAF39EF4420F5398011AF3971
          :10056600EF54EFF53975360AAF39EF54DFF539AF89
          :1005760039EFC413540730E023E535D39401401C0A
          :10058600AF39EF54DFF53912039AC28EE4F531F52F
          :0D0596008DF532F58BAF21EF54EFF52122EA
          :1007B700AF21EF20E00D20B40AAF21EF4401F5216E
          :0407C70075366422FD
          :1005A300AF21EF30E05620B4421536E53664627071
          :1005B3002AE535B40107AF21EF4404F521E535B44D
          :1005C3000A16AF21EF4420F521753364E4F58BF56A
          :1005D3008DAF39EF547FF539120448E536701D7538
          :1005E300360AAF21EF4402F5218011AF21EF54FE0B
          :1005F300F52175360AAF21EF54FDF521AF21EFC385
          :100603001330E023E535D39401401CAF21EF54FDB3
          :10061300F521120448C28EE4F531F58DF532F58BE0
          :08062300AF21EF54DFF52122A5
          :0E07DC00E4FEEEC39F50077D64DDFE0E80F448
          :0107EA0022EC
          :10075400C297C296E4FEEF30E704D2958002C295B8
          :0E076400D297EF25E0FFC2970EBE08EAD296AC
          :010772002264
          :10000E00AF39EFC4540F30E037E5357033AF39EF09
          :10001E00C413540730E023AF39EFC413135401F463
          :10002E005401C4333354C0FFAE39EE54BF4FF539CB
          :10003E00AF39EF54DFF5397536FA852D22852C232D
          :10004E00AF21EF30E00AE535700685292285282399
          :10005E00E52275F00A8425E02434F582E43407F5B0
          :10006E0083E4740193F510E52275F00A84E5F0251A
          :10007E00E02434F582E43407F583E4740193F5113A
          :10008E00E52375F00A8425E02434F582E43407F57F
          :10009E0083E4740193F512E52375F00A84E5F025E7
          :1000AE00E02434F582E43407F583740193F513AF3D
          :1000BE0039EFC41313540330E0035313F7E524C38D
          :1000CE0094324016E5357012AF21EF20E00CAF39B7
          :1000DE00EFC4540F20E0035311F7AF39EFC4540FA0
          :1000EE0020E006AF21EF30E007AF39EF54F7F539D6
          :1000FE00AF39EF131313541F30E013E53530E0081A
          :10010E007510FF7511FF80067512FF7513FFE4F56C
          :10011E002074102520F8E6FF120754E52014600E17
          :10012E001460111460182403701ED292801CC292A7
          :10013E00D2938018C292C293D294C2918012C2926C
          :10014E00C293C294D2918008C292C293C294C291B9
          :10015E007F051207DC7FFF120754C292C293C2942E
          :10016E00C2917F011207DC0520E520C3940440A153
          :01017E00225E
          :1002E800E53570028023E535B40117E530D3940075
          :1002F8004008853022852F23807D852F22852E2357
          :100308008075E535C3940450088527228526238007
          :1003180066E535C394065008852922852823805729
          :10032800E535C394085008852B22852A238048E5A3
          :1003380035C3940A5008852D22852C238039AB3289
          :10034800EB7B00FAEB2531FBE43AFA7C277D10AF12
          :1003580003FE1206B97E007F64CFCDCFCECCCE127D
          :1003680006B98F11AE02AF037C007D641206B98D09
          :1003780010851122851023E52DB52713E52CB52608
          :100388000EAF39EFC41313540330E003D29022C2E6
          :0103980090D4
          :010399002241
          :10070E00E4F52575262675271275280B75290875AB
          :10071E002A0C752B14752D06752C1EF535F52EF538
          :06072E002FF530020773F5
          :030000000207EB09
          :0C07EB00787FE4F6D8FD7581390207CB59
          :1006A700EF8DF0A4A8F0CF8CF0A428CE8DF0A42E67
          :0206B700FE2221
          :1006B900BC000BBE0029EF8DF084FFADF022E4CC25
          :1006C900F875F008EF2FFFEE33FEEC33FCEE9DECEE
          :1006D900984005FCEE9DFE0FD5F0E9E4CEFD22ED34
          :1006E900F8F5F0EE8420D21CFEADF075F008EF2F7E
          :1006F900FFED33FD4007985006D5F0F222C398FD6F
          :050709000FD5F0EA220B
          :00000001FF
          上一頁 1 2 3 下一頁

          關鍵詞: 單片機電子時

          評論


          技術專區(qū)

          關閉
          看屁屁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); })();