Creative Commons images are CC BY-NC-SA 3.0

3.95

added to your
shopping cart

quantity
In stock 451 in stock
3.95 1+ units
3.56 10+ units
3.16 100+ units

Description: Rotary encoders can be used similarly to potentiometers. The difference being that an encoder has full rotation without limits (It just goes round and round). They output gray code so that you can tell how much and in which direction the encoder has been turned. They're great for navigating menu screens and things like that.

This encoder is especially cool because it has a common anode RGB LED built in, as well as a push-button. Look below for the clear knob that goes with this potentiometer.

Features:

  • Switch Travel: 0.5mm
  • Shaft Diameter: 6.0mm
  • Shaft Length: 18mm
  • Vertical Through-Hole Mount
  • 24 Pulses per Rotation
  • Red/Green/Blue LED
  • Pushbutton

Documents:

Comments 55 comments

  • The datasheet doesn’t say which pin goes to what, so here you go: The side with 3 pins is the rotary encoder output - central pin looks to be common. The easiest way to use this with an arduino is to connect common to ground, and then use the Arduino inputs in pull-up mode.

    The LEDs and central button are interfaced using the side with 5 pins. With the shaft facing away from you, looking at the bottom of the device, with the 5-pin side on the top and 3-pin side on the bottom, the pins are: Common (+5v), Blue, Button, Green, Red. Pressing the shaft button shorts the +5v common and the center pin. There are no internal resistors, so be sure to use one on each of the 3 LED pins. Use a 120ohm (or higher) resistor on the red, and a 68ohm (or higher) resistor on the other two, if you’re using 5v.

  • It’s a bit misleading that 4th picture with the breakout board, as that has only the 4 pins of the Red/Green rotary encoder. And on its product page, that refers to THE rotary encoder, not specifically the RG one. One could easily be confused by this and order 2 incompatible items. That said, can’t wait for the RGB rotary breakout board.

  • This (and its right-angle brother) outputs quadrature, not Gray code. (And capitalize “Gray”, since it’s named after a person, Frank Gray.)

    Love the data sheet: “for microscopic current circuits used in electronic equipment”!

    • What’s the difference between quadrature and 2-bit Gray code?

      • Gray code only repeats once around the shaft. You can tell exactly where the shaft is at any time.

        Quadrature code usually repeats around the shaft. You can see the shaft turning but you don’t know the absolute position.

      • In the context of rotary encoders, n-bit Gray code normally refers to absolute rotary encoders, while quadrature usually refers to incremental rotary encoders. In the first type the sensors can continually output a signal the angle of the rotor, even when it is not moving. The second type only outputs a signal when the rotor is turning. So while a signal from both a 2-bit Gray code encoder and a quadrature encoder would look the same during rotation, there are potentially significant differences between the two components that is indicated by the nomenclature. Here’s a Wikipeadia link with some more info.

  • Do these have a ‘Click’ feeling when turned? because these COM-10596 don’t…?

  • Hi, guys- Anyone have an ETA on this unit? Thanks!

  • Can you post the wiring diagram and arduino code for the RGB Rotary encoder that you show in the Product Showcase video, please?

    • The demo code above should work.

      • The demo shows an encoder without the LED and it’s not clear to me that it shows the use of push button. The example shown in the Product Showcase video shows all of these things.

        • I’ll see if we still have that. the push button is just a button, that’s all. you would read it into your microcontroller like any other button. I’ll see if I can dig up the code.

          • This push button is not a normal push button.

            It can only be used “normally low” (if you want to use the LEDs).

            The button shorts the common anode to the center pin of the five pin group.

          • Here you go: code

  • Looks to be a chinese knock-off of the Bourns PEL12T: http://www.bourns.com/data/global/pdfs/PEL12T.pdf.

    Even the LED voltage and current table is identical.

  • Typical.. the week after I order two of the “Bi-Colour” ones, you come out with this.. (sigh).

  • I figured out a way to use this (or any other quadrature/2-bit Gray code encoder) with an Arduino (or other controller). No interrupts, and no switch bounce issues. Just take an old PS/2 ball mouse (NOT optical), open it up, and replace the phototransistor from the optical encoder wheel with three wires going to the A-B-C terminals. You can also replace the left/right mouse button with the switch on this encoder. For some example code, go to http://playground.arduino.cc/ComponentLib/Ps2mouse for a description and library of how to hook up a PS/2 mouse to your Arduino. The mouse controller IC takes care of debouncing, direction sensing, and counting steps between queries. It will also allow you to hook up two encoders (three if the mouse has a scroll wheel) simultaneously.

  • I’ll add to the complaints of poor quality - ordered 2, the first one is now shorting out my arduino. I’ll have to try the second; I may just have to order a better unit from mouser.

  • This encoder seems to be nothing but trouble. Has anyone figured out how to use the Due’s hardware quadrature decoding?

  • I had similar problem as the other users and didn’t manage to use this encoder by using libraries or example code. After a few nights failing to implement existent code I decided to go reverse engineering and figure out what kind of output this thing was giving, and I came out with this code that is working nice with all the units I have (a bought a bunch of them with ringcoder breakouts and everything). This code adds or subtracts from encoderPosition every time the encoder reachs a detent. It will still fail to detect 1% of the times you reach a detent. I used port 52 and 53 since I’m testing this on Arduino DUE (all pins can be used as interrupts), but if you are using other arduinos you should use external interrupt pins.

    int aPin = 52; //connected to the A port
    int bPin = 53; //connected to the B port
    
    void setup()
    {
      Serial.begin(115200);
    
      pinMode(aPin, INPUT); 
      digitalWrite(aPin, HIGH); //pulled-up
      pinMode(bPin, INPUT);
      digitalWrite(bPin, HIGH); //pulled-up
    
      noInterrupts();
      attachInterrupt(aPin, readEncoder, CHANGE);
      attachInterrupt(bPin, readEncoder, CHANGE);
      interrupts();
    
    }
    
    signed int encoderPosition; 
    
    volatile char rotaryData = 0x0;
    
    void readEncoder()
    {
      noInterrupts();
    
      char newData=digitalRead(aPin)
    
  • I just received this interesting little doodad, I’m using it with a Teensy 3.0 and here is some demo Code I wrote for it. Maybe it can help some others out. I haven’t had the issue with it that others have been seeing described as poor build quality. Also, the comment from Member #333036 was pretty spot on as far as pin out. I used the encoder library from PJRC found here example which handles this device well. It does however increment +-4 every tick of the detent so just be careful when coding.

    #include 
    
    Encoder encoder(A5, A4); //These 2 pins are A and B of the encoder side, C is connected to ground
    
    const int redPin =  10; 
    const int greenPin =  A8;
    const int bluePin =  9;
    volatile boolean encoder_button = false;
    
    void setup() {
      Serial.begin(9600);
      pinMode(A3, INPUT);
      pinMode(redPin, OUTPUT);
      pinMode(greenPin, OUTPUT);
      pinMode(bluePin, OUTPUT);
      attachInterrupt(A3, buttonPush, CHANGE);
    }
    
    void loop() {
      int32_t value;
      value = encoder.read();
        Serial.print("value = ");
        Serial.println(value);
    
      if (Serial.available()) {
        Serial.read();
        Serial.println("Reset Encoder to Zero");
        encoder.write(0);
      }
      if(encoder_button)
      {
        for(int i=0; i< 20; i++) //Careful with this if you or a friend has epilepsy 
        {
          setColor(255, 255, 255);
          delay(10);
          setColor(0, 0, 0);
          delay(100);
        }
        encoder_button = false;
        Serial.println("Button Pushed");
      }
      else
      {
        setColor(value,0,0);
        delay(1000);  
        setColor(0,value,0);
        delay(1000);
        setColor(0,0,value);
        delay(1000);
      }
    }
    
    void buttonPush()
    {
      encoder_button = true;
    }
    
    void setColor(int red, int green, int blue)
    {
      analogWrite(redPin, red);
      analogWrite(greenPin, green);
      analogWrite(bluePin, blue);  
    }
    
  • I ordered some of these the other day, and what I received today is not what is described here. The shaft has no threads and is much smaller than the included mounting nut and washer, so they are basically useless, as I cannot panel mount them. Further, they do not ‘click’ as you rotate them, it is just a smooth rotation. The part number on the bags is as listed on this page. Rather frustrating, I was in the middle of a project with my daughter and needed them, now we’re going to have to wait.

    • Just thought I’d give an update here. I had indeed received the wrong parts, and techsupport sent me the correct ones, got them a couple days ago. Problem solved, thanks a bunch guys!

    • Sorry about that, email us at techsupport@sparkfun.com and we’ll see if we can get to the bottom of this and get you what you need.

  • Nat2 | last year * 1

    Just wanted to mention that you can easily remove the detents on these encoders. Just open the 4 metal legs, take it apart and flip the copper spacer/detents ring. You might want to flatten it a bit for best results.

  • These are common CATHODE, not common anode.

    As such you can use single resistor on the common side for all three LEDs

  • After reading the reviews, I was a little skeptical of the quality I would get, however I haven’t found anything that offers the exact same product as this. So I ordered 2, incase one didn’t work. Well after spending hours trying to figure out why one wasn’t working, I looked at the second one to find that it wouldn’t work either. The switch (rotary encoder), in the resting position, would never make contact with the common pin (labeled C I believe in the datasheet). While rotating, the outputs (A and B) would close to the common ( C ) as they should (pre the datasheet), but NEVER would rest where they were supposed to. After taking them both apart, it seems that the divots that are supposed to hold the shaft in position are misaligned. So when you let go and the shaft “clicks” to a spot, it is always open (doesn’t make contact). I seriously doubt this is how it is supposed to operate! To fix it (so to speak) I flipped the copper sheet around that makes the shaft stay (and click) to each divot. Now it spins smoothly AND works like it’s supposed to! I can’t believe how cheap this was made! So keep in mind that this is junk and you’ll have to fix it yourself.

    P.S. I would have returned it on the spot, but I already built my enclosure to the dimensions for this switch and like I said, nothing I have found fits as a replacement.

    • I am having the same issue. If/when rotation is detected, it is immediately cancelled by an opposing rotation detected at the same time. Turning the encoder one detent at a time, will not increment a counter. This is already soldered into the RingCoder breakout and I doubt it’s going to come back out easily.

  • According to the datasheet, it looks as if this is a QUADRATURE output encoder, not GRAY CODE.

    Is this so? Or does it actually put out GRAY CODE as it says in the description?

    If so, how does it put out 24 pulses with four pins?

    Am I missing something.

    Confused in Saint Paul

    • Depending on how pedantic you want to be, 2-bit Gray code and quadrature could be defined as the same thing; but as Gray code is generally applied (usually with higher bit resolutions) to absolute encoders, I understand the confusion. Consider this a quadrature (incremental) encoder. The three pins on one side are the encoder; the five pins on the other side are for the RGB LED and pushbutton switch.

  • Hello all, has anyone code like the product video using a 20m2 picaxe? I’ve goggled until my fingers can’t goggle anymore.

    Curt

  • I’m getting around 4 interruption per click, is it something related to what they call “chattering” on the datasheet ?

  • Hi all I got two of these and started designing something in SketchUp so I thought I’d share this model that I created for it. SketchUP COM-10982 Model

  • Could you specify that this product is not breadboard friendly? apparently you only specify this when you have a breakout board for it….

  • Bad quality encoders received. I don’t know where to post this, so I add a comment. I have seen that SparkFun moderators often post answers and/or hints to user comments/questions. Looking forward for this.

    I’m sorry to say this, but the encoders you sent me are of poor quality. The “rest position” of the encoders is actually connecting one of the outputs to the common if resting in a 120-degrees area (maybe more). I state that I did not subject the encoders to any mechanical factors except when adding the clear plastic knob on top of them (extreme care is taken, I was never even close to the 5kgf in the datasheet).

    The encoders seem to be faulty. I will test the remaining 3 encoders this afternoon and keep you updated with the results. I noticed this problem yesterday late-evening while struggling with Gray debouncing inside the code. For two thirds of the rotation the algorithm worked but for one third it didn’t. I have also tested the encoders against two LEDs, that is how I noticed the awkward “rest position”… I only tested 2 encoders (of the 5 I bought last month) and both seem to have the same problem. I dismantled one of the two faulty encoders but I saw no problem; I’ve put it back and it works the same. Still, maybe the leads are miss-aligned, my eye-meter isn’t micrometer-accurate. The second faulty encoder was not dismantled but it behaves the same.

    Any hint?

    Thanks, ro0ter

    • UPDATE: A total of three encoders of the 5 I bought have this problem. I further analyzed the problem and I noticed that the rotary shaft of the faulty rgb encoders has a margin (it rattles a bit unlike the shaft of the working rgb encoders). I was able to fix the encoder I dismantled by tightening it better. I’m not sure how it will hold in time since the metal claws are a bit fragile now due to the bending.

      The rotary encoders that failed: 1) hand-soldered ~250°C, knob added and removed, dismantled, tightened back, works better now (shaft rattles less) 2) hand-soldered ~250°C, knob added and removed, shaft rattles a lot 3) brand-new from the bag, not soldered, no knob added to this one, seems not to have that clicky feeling so pronounced.

      Sparkfun, I thought you sell better products, really… I was thinking to return them but the shipping to USA is like $40-50… It’s more expensive than the total value of these 5 encoders plus the original shipping… It ain’t worth it sending them back…

      I wonder if anyone else has problems with these encoders. Please let me know about this.

      Regards, ro0ter

  • Any ETA on when these will be available again?

  • The button shorts the common anode of the LEDs to th center pin of the five pin group.

    Connect the center pin to your uC with a pull-down resister to monitor its position.

  • can anyone give me some info on how to debounce the push button in this?

  • Does anyone have a wiring diagram or tutorial on how to get the LEDs on this thing to work? Thanks

  • Very nice :)

  • Pity they are mechanical instead of optical :(

  • Are you making a break-out board for this part, and is it going to have holes for pins that are aligned on both sides so it fits square in a breadboard or protoboard? (not like the break-out for the red/green illuminated rotary encoder where the holes are not aligned).

    • Here’s a break-out I’m using until SparkFun comes out with theirs.

      http://www.batchpcb.com/index.php/Products/78935

    • Yes, but it’s going to have some other stuff attached. This should be in the eagle library.

  • More importantly, is that really the datasheet for this part? No mention of a switch or LEDS, just the two quadrature switches.

  • So is this an encoder or a potentiometer? “Look below for the clear knob that goes with this potentiometer.” Same thing on the right-angled version’s page. Now, I don’t know if you also carry an illuminated potentiometer, but otherwise I would suggest also changing the “Clear Plastic Knob” product page, which talks about an illuminated pot.

    • The knob page does now mention it’s for encoders, but this' and its right-angled brother’s product pages still say “Look below for the clear knob that goes with this potentiometer.” at the end of the second paragraph :(


Related Products