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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 51單片機制作霓虹燈的程序+電路圖

          51單片機制作霓虹燈的程序+電路圖

          作者: 時間:2016-11-30 來源:網(wǎng)絡(luò) 收藏
          霓虹燈的電路圖:

          霓虹燈的51單片機程序:
          #include
          #define uchar unsigned char
          #define uint unsigned int
          sbit RED_LED = P1^0; //端口定義.
          sbit GREEN_LED = P1^1;
          sbit YELLOW_LED = P1^2;
          uint flicker,i,n;
          void int0()
          {
          TMOD=0x01;
          TH0=0x3C;
          TL0=0xAF;
          TR0=1; //啟動定時器。
          ET0=1; //開定時器中斷.
          EA=1; //開總中斷
          }
          void main() //主函數(shù)。
          {
          n=0;
          i=0;
          GREEN_LED=1;
          YELLOW_LED=1;
          flicker=0;
          int0();
          while(1)
          {
          if(0<=n&&n<20)
          {
          YELLOW_LED=1;
          GREEN_LED=1;
          RED_LED=flicker;
          }
          if(20<=n&&n<40)
          {
          RED_LED=1;
          YELLOW_LED=1;
          GREEN_LED=flicker;
          }
          if(40<=n&&n<60)
          {
          RED_LED=1;
          GREEN_LED=1;
          YELLOW_LED=flicker;
          if(n==59)
          n=0;
          }
          }
          }
          void Time0() interrupt 1
          {
          TR0=0;
          i++;
          if(i==10)
          {
          flicker=~flicker;
          i=0;
          n++;
          }
          TH0=0x3C;
          TL0=0xAF;
          TR0=1;
          }
          下面是另一個用51單片機的霓虹燈2:
          如果網(wǎng)頁復制的代碼無法編譯成功可以從:http://www.51hei.com/f/nhddpj_c.rar 這個鏈接下載
          #include
          #define uchar unsigned char
          #define uint unsigned int
          uchar ss[]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,
          0x00,0xff,0x00,0xff,0x00,0x01,0x03,0x06,
          0x0c,0x18,0x30,0x60,0xc0,0x80,0x00,0xff,
          0x00,0xff,0x00,0xff,0x00,0x01,0x03,0x07,
          0x0e,0x1c,0x38,0x70,0xe0,0xc0,0x80,0x00,
          0xff,0x00,0xff,0x00,0x01,0x03,0x07,0x0f,
          0x1e,0x3c,0x78,0xf0,0xe0,0xc0,0x80,0xff,
          0x00,0xff,0x00,0xff,0x00,0x78,0xf0,0xff,
          0x00,0xff,0x00,0x80,0x40,0x20,0x10,0x08,
          0x04,0x02,0x01,0xff,0x00,0xff,0x00,0xff,
          0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,
          0xff,0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01};
          /*數(shù)組中為霓虹燈閃爍花樣,單流水,雙流水,三流水,四流水和倒流*/
          uint m,n,i;
          void delay(m)
          {
          while(m--)
          for(i=0;i<120;i++);
          }
          void main() //主函數(shù)。
          {
          while(1)
          {
          P1=ss[n];
          P3=ss[n];
          delay(400);
          P1=0x00;
          n++;
          if(n==96)
          n=0;
          }
          }


          關(guān)鍵詞: 51單片機霓虹

          評論


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