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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 51單片機(jī)時鐘秒表課程設(shè)計

          51單片機(jī)時鐘秒表課程設(shè)計

          作者: 時間:2016-11-29 來源:網(wǎng)絡(luò) 收藏

          void Delayms(int ms)

          {

          while(ms)

          {

          unsigned char i;

          ms--;

          for (i=0; i<240; i++);

          }

          }

          void display()

          {

          char v,c;

          P3=0x11;

          v=Leds[Ledc];

          c=LEDTAB[v & 0x0f];

          if (v&0x10) c|=0x80;

          P2=c;

          P3=Ledc;

          Ledc++;

          if (Ledc>=8) Ledc=0;

          }

          void readkey() //讀按鍵

          {

          if(start==0) isStart = 1; //真為開始

          if(stop==0) isStart = 0; //假為停止

          if(key0 == 0) num_count = stu_num0; //選擇曾路榮

          if(key1 == 0) num_count = stu_num1;//選擇張洪榮

          if(key2 == 0) num_count = stu_num2;

          if(key3 == 0) num_count = stu_num3;

          if(key4 == 0) num_count = stu_num4;

          if(key5 == 0) num_count = stu_num5;

          }

          void t0int() interrupt 1 //1ms定時器中斷服務(wù)函數(shù)

          {

          TH0=(-1000)>>8;

          TL0=-1000;

          display();

          readkey();

          T1msc++;

          if (isStart) //開始倒計時

          {

          if ((T1msc%100)==0) //滿 0.1秒

          {

          temp--;

          if(temp==-1)

          {

          num_count--;

          temp = 10; //0.1秒恢復(fù)9

          }

          }

          if(num_count == -1) //

          {

          num_count = 99;

          num--;

          if(num == -1) num = 99;

          }

          }

          if (T1msc>=1000)

          {

          T1msc=0;

          }

          }

          void NumToLeds()

          {

          Leds[1]=num/10%10;

          Leds[2]=num%10;

          Leds[3]=num_count/10%10;

          Leds[4]=num_count%10+0x10;

          Leds[5]=temp; //0.1秒顯示

          }

          void main()

          {

          Delayms(10);

          TMOD=0x01;

          TR0=1;

          ET0=1;

          EA=1;

          while(1)

          {

          NumToLeds(); //送數(shù)據(jù)

          }

          }


          上一頁 1 2 下一頁

          評論


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