360度PWM旋转编码器突破

      360度PWM旋转编码器突破

      USD
      Model #
      Quantity
      qty limit cart limit
      In Stock

      Add 

      Warranty Plus

      Warranty Plus:
      Your product will be replaced (including free shipping) with a new one within 12 months of purchase, even if it is damaged due to improper wiring, incorrect usage, a problem in the electrical installation or any other circumstance.

      Standard Warranty:
      12 month warranty comes with every purchase. Covers malfunctions when it is used within the described conditions/limits.

       +8% 

      Shipping Cost Estimator

      Note: You must have items in your cart already before you can see the estimated costs to ship your cart. This shipping tool will estimate the total shipping cost for your entire basket.

      描述

      这种类型的开关是增量旋转编码器。事实上,它是所有旋转编码器中最广泛使用的,因为它的低成本和提供可以轻松解释以提供相关信息(例如速度)的信号的能力。

      通过旋转,旋转编码器可以在旋转过程中以正向和反向方向计数输出脉冲频率,这与旋转电位计计数器不同而不计算限制。使用旋转编码器上的按钮,它可以从零开始重置为初始状态。

      测试代码

      int redpin = 2;
      int yellowpin = 3;
      int greenpin = 4;
      int apin = 6;
      int bpin = 7;
      int buttonpin = 5;
      int状态= 0;
      int longperiod = 5000; //绿色或红色的时间
      int shortperiod = 700; //更改的时间段
      int targetCount = shortperiod;
      int count = 0;
      void setup()
      {
        pinmode(apin,输入);
        pinmode(bpin,输入);
        pinmode(buttonpin,输入);
        pinmode(redpin,输出);
        pinmode(Yellowpin,输出);
        pinmode(greenpin,输出);
      }
      void loop()
      {
        计数++;
        if(DigitalRead(buttonpin))
        {
        Setlights(高,高,高);
        }
        别的
        {
        int change = getenCoderTurn();
        int newperiod = longperiod +(更改 * 1000);  
        if(newperiod> = 1000 && newperiod <= 10000)
          {
        longperiod = newperiod;
          }
        if(count> targetCount)
          {
        setState();
        计数= 0;
          }
        }
        延迟(1);
      }
      int getencoderturn()
      {

       //返回-1、0或+1
        静态Int Olda = low;
        静态int oldb = low;
        int结果= 0;
        int newa = digitalread(apin);
        int newb = digitalread(bpin);
        if(newa!= olda || newb!= oldb)
        {
        //发生了变化
        如果(olda ==低&& newa ==高)
          {
        结果= - (OldB * 2-1);
          }
        }
        olda = newa;
        oldb = newb;
        返回结果;
      }
      int setState()
        {
        如果(状态== 0)
          {
        Setlights(高,低,低);
        targetCount = longperiod;
        状态= 1;
          }
        否则(状态== 1)
          {
        Setlights(高,高,低);
        TargetCount = Shortperiod;
        状态= 2;
          }
        否则(状态== 2)
          {
        Setlights(低,低,高);
        targetCount = longperiod;
        状态= 3;
          }
        否则(状态== 3)
          {
        Setlights(低,高,低);
        TargetCount = Shortperiod;
        状态= 0;
          }
        }
      void setlights(int红色,int黄色,int绿色)
      {
        DigitalWrite(Redpin,Red);
        DigitalWrite(黄金报,黄色);
        DigitalWrite(Greenpin,Green);

      Frequently Bought Together

      Total Price: