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

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 51單片機(jī)的七彩LED燈漸變調(diào)光調(diào)色程序

          51單片機(jī)的七彩LED燈漸變調(diào)光調(diào)色程序

          作者: 時(shí)間:2016-12-01 來(lái)源:網(wǎng)絡(luò) 收藏

          //***********************************************************************
          //Pattern4() 花樣函數(shù)4-------------7彩漸變
          //***********************************************************************
          void Pattern34()
          {
          Gra = 1; //漸變位 = 1
          }
          /*********************************************************/
          // 定時(shí)器0中斷服務(wù)程序
          /*********************************************************/
          void time0(void) interrupt 1
          {
          TR1 =0;
          TF0 =0;
          TH0=0xdb; //重新寫入初值
          TL0=0xff;
          if(!Gra) //執(zhí)行跳變程序
          {
          count ++;
          if(count > Speed)
          {
          LEDdelay = 1;
          count = 0;
          }
          }
          if(Gra)
          {
          TR1 = 1; //開(kāi)啟TR1;
          if(!BP) //
          {
          if(Gra7)
          {
          P1 = led1[ledcount1]; //10ms到,亮相應(yīng)的LED
          }
          if(Gra3)
          {
          P1 = led3[ledcount1]; //10ms到,亮相應(yīng)的LED
          }
          Pulse++;
          value();
          if(Pulse >= Period)
          {
          Pulse = Period;
          BP = 1; //一個(gè)周期完成轉(zhuǎn)換模式
          }
          }
          if(BP)
          {
          if(Gra7)
          {
          P1 = led1[ledcount1]; //10ms到,亮相應(yīng)的LED
          }
          if(Gra3)
          {
          P1 = led3[ledcount1]; //10ms到,亮相應(yīng)的LED
          }
          value();
          Pulse--; //脈沖個(gè)數(shù)
          if(Pulse == 0)
          {
          Pulse = 0;
          BP = 0; //一個(gè)周期完成轉(zhuǎn)換模式
          ledcount1++;
          if(Gra7)
          {
          if(ledcount1 > 11)
          {
          ledcount1 = 0;
          }
          Gra7 = 0;
          }
          if(Gra3)
          {
          if(ledcount1 > 2)
          {
          ledcount1 = 0;
          }
          Gra3 = 0;
          }
          }
          }
          }
          }
          /*********************************************************/
          // 定時(shí)器1中斷服務(wù)程序
          /*********************************************************/
          void timer1() interrupt 3
          {
          PWM --;
          TH1 = 0xff; //0.05ms(20000分之一秒)
          TL1 = 0xD1;
          if(PWM == 0)
          {
          P1 = 0;
          TR1 = 0;
          }
          }
          /*********************************************************/
          // 外部中斷0中斷服務(wù)程序 下降沿觸發(fā)
          /*********************************************************/
          void extern0(void) interrupt 0
          {
          IE0 = 0; // 清標(biāo)志位
          excount++;
          if(excount>50) // 50大約3秒
          {
          EA = 0;
          //P1_5 = 1;
          excount = 0;
          Reset();
          }
          }

          上一頁(yè) 1 2 下一頁(yè)

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