Breakout codificatore rotativo PWM a 360 gradi

      Breakout codificatore rotativo PWM a 360 gradi

      USD
      Model #
      Quantity
      qty limit cart limit

      Add Warranty Plus +8%

      Standard Warranty (included in purchase price): 12 month warranty due to device malfunctions when it is used within the described conditions/limits.

      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.

      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.

      Descrizione

      Questo tipo di interruttore è un codificatore rotativo incrementale.  È un dato di fatto, è il più utilizzato di tutti gli encoder rotativi a causa del suo basso costo e della capacità di fornire segnali che possono essere facilmente interpretati per fornire informazioni relative al movimento come la velocità.

      Ruotando, l'encoder rotante può contare la frequenza dell'impulso di uscita in direzione positiva e inversa durante la rotazione, a differenza di un contatore del potenziometro rotante senza limiti di conteggio. Con il pulsante sull'encoder rotativo, può essere ripristinato al suo stato iniziale a partire da zero.

      Codice di test

      int redPin = 2;
      int yellowPin = 3;
      int greenPin = 4;
      int aPin = 6;
      int bPin = 7;
      int buttonPin = 5;
      stato int = 0;
      int longPeriod = 5000; Tempo al verde o al rosso
      int shortPeriod = 700; Periodo di tempo durante la modifica
      int targetCount = shortPeriod;
      int count = 0;
      annulla impostazione()
      {
      pinMode(aPin, INPUT);
      pinMode(bPin, INPUT);
      pinMode(buttonPin, INPUT);
      pinMode(redPin, OUTPUT);
      pinMode(yellowPin, OUTPUT);
      pinMode(greenPin, OUTPUT);
      }
      loop void()
      {
      count++;
      if (digitalRead(buttonPin))
        {
      setLights(HIGH, HIGH, HIGH);
        }
      Altro
        {
      int change = getEncoderTurn();
      int newPeriod = longPeriod + (variazione * 1000);
      if (newPeriod >= 1000 & newPeriod <= 10000)
          {
      longPeriod = newPeriod;
          }
      if (conteggio > targetCount)
          {
      setState();
      conteggio = 0;
          }
        }
      ritardo(1);
      }
      int getEncoderTurn()
      {

      ritorno -1, 0 o +1
      static int oldA = LOW;
      static int oldB = LOW;
      int result = 0;
      int newA = digitalRead(aPin);
      int newB = digitalRead(bPin);
      if (newA != oldA || newB != oldB)
        {
      qualcosa è cambiato
      if (oldA == LOW & newA == HIGH)
          {
      risultato = -(oldB * 2 - 1);
          }
        }
      oldA = newA;
      oldB = newB;
      risultato di ritorno;
      }
      int setState()
        {
      if (stato == 0)
          {
      setLights(HIGH, LOW, LOW);
      targetCount = longPeriod;
      stato = 1;
          }
      else if (stato == 1)
          {
      setLights(HIGH, HIGH, LOW);
      targetCount = shortPeriod;
      stato = 2;
          }
      else if (stato == 2)
          {
      setLights(LOW, LOW, HIGH);
      targetCount = longPeriod;
      stato = 3;
          }
      else if (stato == 3)
          {
      setLights(LOW, HIGH, LOW);
      targetCount = shortPeriod;
      stato = 0;
          }
        }
      void setLights(int rosso, int giallo, int verde)
      {
      digitalWrite(redPin, rosso);
      digitalWrite(yellowPin, giallo);
      digitalWrite(greenPin, verde);