20% OFF shipping at os-recordingstudio.com on orders over $79 + up to 10% OFF products
os-recordingstudio.com
home > 360 Degree PWM Rotary Encoder Breakout > 360 Degree PWM Rotary Encoder Breakout
download picture
360 Degree PWM Rotary Encoder Breakout360 Degree PWM Rotary Encoder Breakout Description: This type of switch is an incremental rotary encoder. As a matter of fact, it is the most widely used of all rotary encoders due to its low cost and ability to provide signals that can be easily interpreted to provide motion related information such as velocity. By rotating, the rotary encoder can count the output pulse frequency in positive and reverse direction during rotation, unlike a rotary
Shopping security

Shopping security

Each payment you make on thelockerguy is secured with strict SSL encryption and PCI DSS data protection protocols

360 Degree PWM Rotary Encoder Breakout

Description:

This type of switch is an incremental rotary encoder.  As a matter of fact, it is the most widely used of all rotary encoders due to its low cost and ability to provide signals that can be easily interpreted to provide motion related information such as velocity.

By rotating, the rotary encoder can count the output pulse frequency in positive and reverse direction during rotation, unlike a rotary potentiometer counter without counting limitation. With the button on the rotary encoder, it can be reset to its initial state starting from zero.

Testing code:

int redPin = 2;
int yellowPin = 3;
int greenPin = 4;
int aPin = 6;
int bPin = 7;
int buttonPin = 5;
int state = 0;
int longPeriod = 5000; // Time at green or red
int shortPeriod = 700; // Time period when changing
int targetCount = shortPeriod;
int count = 0;
void setup()
{
  pinMode(aPin, INPUT);
  pinMode(bPin, INPUT);
  pinMode(buttonPin, INPUT);
  pinMode(redPin, OUTPUT);
  pinMode(yellowPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
}
void loop()
{
  count++;
  if (digitalRead(buttonPin))
  {
    setLights(HIGH, HIGH, HIGH);
  }
  else
  {
    int change = getEncoderTurn();
    int newPeriod = longPeriod + (change * 1000);  
    if (newPeriod >= 1000 && newPeriod <= 10000)
    {
      longPeriod = newPeriod;
    }
    if (count > targetCount)
    {
      setState();
      count = 0;
    }
  }
  delay(1);
}
int getEncoderTurn()
{

 // return -1, 0, or +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)
  {
    // something has changed
    if (oldA == LOW && newA == HIGH)
    {
      result = -(oldB * 2 - 1);
    }
  }
  oldA = newA;
  oldB = newB;
  return result;
}
int setState()
  {
    if (state == 0)
    {
      setLights(HIGH, LOW, LOW);
      targetCount = longPeriod;
      state = 1;
    }
    else if (state == 1)
    {
      setLights(HIGH, HIGH, LOW);
      targetCount = shortPeriod;
      state = 2;
    }
    else if (state == 2)
    {
     setLights(LOW, LOW, HIGH);
      targetCount = longPeriod;
      state = 3;
    }
    else if (state == 3)
    {
      setLights(LOW, HIGH, LOW);
      targetCount = shortPeriod;
      state = 0;
    }
  }
void setLights(int red, int yellow, int green)
{
  digitalWrite(redPin, red);
  digitalWrite(yellowPin, yellow);
  digitalWrite(greenPin, green);

360 Degree PWM Rotary Encoder Breakout

Item no : 147602716
sold recently : Login >>
US$ 130.00
Pay in 4 interest-free payments of $32.50 Learn more
Min. order: 1piece

Shipping Estimate
USA
  • USA
  • CAN

Ships within 48 hours · Estimated delivery Jun 20 - Jun 25

Enjoy 20% off shipping

US$ 130.00

1-11

US$ 117.00

12-35

US$ 91.00

36-59

US$ 78.00

60+

US$40

Get now

Sign up to your membership to get coupons up to

15%

Get now

Opportunity to enjoy order discount up to 15% off

Please add the products
Shipping Notes
  • Free Standard Shipping on $100+ Orders to the USA.
  • Except Preorder products are shipped in 48 hours.
  • Delivery to the USA:
  1. Standard Shipping : 3-10 business days
  • If time is of the essence, please consider selecting expedited delivery for faster service.
Exchange/Return Notes
  • We offer a 30-day return/exchange service after receiving.
  • Final sale items are not eligible for returns or exchanges.
  • To process your return/exchange, please contact us at [email protected]
  • Please click here for more details>>> Return & Exchange Policy

Discover Niche Categories That Outsell

Top-Converting Item to Boost Your Average Order

recommand products

Related Searches