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

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > STM32簡(jiǎn)易交通燈設(shè)計(jì)(定時(shí)可調(diào))

          STM32簡(jiǎn)易交通燈設(shè)計(jì)(定時(shí)可調(diào))

          作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 收藏
          //按鍵key1 設(shè)置紅燈時(shí)間
          按鍵key2 設(shè)置綠燈時(shí)間
          按鍵key3設(shè)置黃燈時(shí)間
          #include
          #include "sys.h"

          #include "delay.h"
          #include "usart.h"
          #include "stdlib.h"

          static int G=0,R=0,Y=0; //設(shè)置綠,紅,黃燈時(shí)間變量

          #include "lcd.h"
          #include "key.h"
          #include "time.h"

          //----------- 按鍵函數(shù)----------
          void scan_key1()
          {
          static u8 i,j;
          if(key1==0)
          {
          if(i==0)
          {
          j++;
          if(j>3)
          {
          i=1;j=0;
          R++;
          if(R>20)R=0;
          printf("key1 is inputed ");
          }
          }
          }
          else
          {
          i=j=0;
          }
          }

          void scan_key2()
          {
          static u8 i,j;
          if(key2==0)
          {
          if(i==0)
          {
          j++;
          if(j>3)
          {
          i=1;j=0;
          G++;
          if(G>20)G=0;
          printf("key2 is inputed. ");
          }
          }
          }
          else
          {
          i=j=0;
          }
          }

          void scan_key3()
          {
          static u8 i,j;
          if(key3==1)
          {
          if(i==0)
          {
          j++;
          if(j>3)
          {
          i=1;j=0;
          Y++;
          if(Y>20)Y=0;
          printf("key3 is inputed. ");
          }
          }
          }
          else
          {
          i=j=0;
          }
          }


          //各指示燈顯示秒數(shù)函數(shù)
          void LED_RED(u8 k)
          {
          LCD_ShowNum(120,55,k,2,16);
          }
          void LED_YELLOW(u8 k)
          {
          LCD_ShowNum(120,145,k,2,16);
          }
          void LED_GREEN(u8 k)
          {
          LCD_ShowNum(120,235,k,2,16);
          }

          上一頁(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); })();