日本a√视频在线,久久青青亚洲国产,亚洲一区欧美二区,免费g片在线观看网站

        <style id="k3y6c"><u id="k3y6c"></u></style>
        <s id="k3y6c"></s>
        <mark id="k3y6c"></mark>
          
          

          <mark id="k3y6c"></mark>

          新聞中心

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

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

          作者: 時間:2016-12-01 來源:網(wǎng)絡 收藏

          //***********************************************************************
          //Pattern4() 花樣函數(shù)4-------------7彩漸變
          //***********************************************************************
          void Pattern34()
          {
          Gra = 1; //漸變位 = 1
          }
          /*********************************************************/
          // 定時器0中斷服務程序
          /*********************************************************/
          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; //開啟TR1;
          if(!BP) //
          {
          if(Gra7)
          {
          P1 = led1[ledcount1]; //10ms到,亮相應的LED
          }
          if(Gra3)
          {
          P1 = led3[ledcount1]; //10ms到,亮相應的LED
          }
          Pulse++;
          value();
          if(Pulse >= Period)
          {
          Pulse = Period;
          BP = 1; //一個周期完成轉(zhuǎn)換模式
          }
          }
          if(BP)
          {
          if(Gra7)
          {
          P1 = led1[ledcount1]; //10ms到,亮相應的LED
          }
          if(Gra3)
          {
          P1 = led3[ledcount1]; //10ms到,亮相應的LED
          }
          value();
          Pulse--; //脈沖個數(shù)
          if(Pulse == 0)
          {
          Pulse = 0;
          BP = 0; //一個周期完成轉(zhuǎn)換模式
          ledcount1++;
          if(Gra7)
          {
          if(ledcount1 > 11)
          {
          ledcount1 = 0;
          }
          Gra7 = 0;
          }
          if(Gra3)
          {
          if(ledcount1 > 2)
          {
          ledcount1 = 0;
          }
          Gra3 = 0;
          }
          }
          }
          }
          }
          /*********************************************************/
          // 定時器1中斷服務程序
          /*********************************************************/
          void timer1() interrupt 3
          {
          PWM --;
          TH1 = 0xff; //0.05ms(20000分之一秒)
          TL1 = 0xD1;
          if(PWM == 0)
          {
          P1 = 0;
          TR1 = 0;
          }
          }
          /*********************************************************/
          // 外部中斷0中斷服務程序 下降沿觸發(fā)
          /*********************************************************/
          void extern0(void) interrupt 0
          {
          IE0 = 0; // 清標志位
          excount++;
          if(excount>50) // 50大約3秒
          {
          EA = 0;
          //P1_5 = 1;
          excount = 0;
          Reset();
          }
          }

          上一頁 1 2 下一頁

          評論


          技術專區(qū)

          關閉