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

          新聞中心

          自制電子時(shí)鐘

          作者: 時(shí)間:2016-11-29 來源:網(wǎng)絡(luò) 收藏
          仿真出來一個(gè)可以調(diào)時(shí)間的鐘。下面是仿真圖片。
          下面是核心的單片機(jī)編程:
          #include
          #define ulong unsigned long
          #define uint unsigned int
          sbit duan=P2^0;
          sbit wei=P2^1;
          sbit led=P2^2;
          sbit key1=P1^0;
          sbit key2=P1^1;
          sbit key3=P1^2;
          sbit key4=P1^3;
          sbit key5=P1^4;
          uint code shuju1[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
          uint code shuju2[]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10};//為讓小數(shù)點(diǎn)點(diǎn)亮,另建一個(gè)數(shù)組
          void delayms(uint);
          void keyscan();
          void Play(uint t);
          void display(uint,uint,uint,uint,uint,uint);
          ulong num;
          uint i,j,num1,shi,fen,miao,sw,w,q,b,s,g,h,f,m;
          void main()
          {
          TMOD=0x10;
          TH1=(65536-45872)/256;
          TL1=(65536-45872)%256;
          EA=1;
          ET1=1;
          TR1=1;
          while(1)
          {
          keyscan();
          display(sw,w,q,b,s,g);
          }
          }
          void display(uint sw,uint w,uint q,uint b,uint s,uint g)
          {
          duan=1; //打開 段 鎖存端
          P3=shuju1[g]; //傳入數(shù)據(jù)
          duan=0; //關(guān)閉 段 鎖存端
          P3=0xff; //清影
          wei=1; //打開 位 鎖存端
          P0=0x01; //傳入位選數(shù)據(jù)
          wei=0; //關(guān)閉 位 鎖存端
          delayms(5); //延時(shí)
          duan=1; //打開 段 鎖存端
          P3=shuju1[s]; //傳入數(shù)據(jù)
          duan=0; //關(guān)閉 段 鎖存端
          P3=0xff; //清影
          wei=1; //打開 位 鎖存端
          P0=0x02; //傳入位選數(shù)據(jù)
          wei=0; //關(guān)閉 位 鎖存端
          delayms(5); //延時(shí)
          duan=1; //打開 段 鎖存端
          P3=shuju2[b]; //傳入數(shù)據(jù)
          duan=0; //關(guān)閉 段 鎖存端
          P3=0xff; //清影
          wei=1; //打開 位 鎖存端
          P0=0x04; //傳入位選數(shù)據(jù)
          wei=0; //關(guān)閉 位 鎖存端
          delayms(5); //延時(shí)
          duan=1; //打開 段 鎖存端
          P3=shuju1[q]; //傳入數(shù)據(jù)
          duan=0; //關(guān)閉 段 鎖存端
          P3=0xff; //清影
          wei=1; //打開 位 鎖存端
          P0=0x08; //傳入位選數(shù)據(jù)
          wei=0; //關(guān)閉 位 鎖存端
          delayms(5); //延時(shí)
          duan=1; //打開 段 鎖存端
          P3=shuju2[w]; //傳入數(shù)據(jù)
          duan=0; //關(guān)閉 段 鎖存端
          P3=0xff; //清影
          wei=1; //打開 位 鎖存端
          P0=0x10; //傳入位選數(shù)據(jù)
          wei=0; //關(guān)閉 位 鎖存端
          delayms(5); //延時(shí)
          duan=1; //打開 段 鎖存端
          P3=shuju1[sw]; //傳入數(shù)據(jù)
          duan=0; //關(guān)閉 段 鎖存端
          P3=0xff; //清影
          wei=1; //打開 位 鎖存端
          P0=0x20; //傳入位選數(shù)據(jù)
          wei=0; //關(guān)閉 位 鎖存端
          delayms(5); //延時(shí)
          }
          void delayms(uint xms)
          {
          for(i=xms;i>0;i--)
          for(j=110;j>0;j--);
          }
          上一頁 1 2 下一頁

          關(guān)鍵詞: 電子時(shí)

          評(píng)論


          技術(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); })();