×

Please see all COVID-19 updates here as some shipments may be delayed due to CDC safety and staffing guidelines. If you have an order or shipping question please refer to our Customer Support page. For technical questions please check out our Forums. Thank you for your continued support.

Michel Jansen

Member Since: February 28, 2011

Country: United States

  • For whoever may find it useful: I used a bunch of these rotary encoders for a prototyping project and I wrote a simple wrapper library around them.
    You can find the code on GitHub:
    https://github.com/micheljansen/arduino-rotary-knob
    #define PIN_OFFSET 22
    #define NUMKNOBS 6
    Knob knobs[NUMKNOBS];
    void setup()
    {
    for(int i = 0; i < NUMKNOBS; i++) {
    knobs[i].setup(PIN_OFFSET + 2i, PIN_OFFSET + 2i + 1);
    // abuse output pins for gnd
    pinMode(i+2, OUTPUT);
    digitalWrite(i+2, LOW);
    }
    Serial.begin(9600);
    }
    void loop()
    {
    for(int i = 0; i < NUMKNOBS; i++) {
    int dir = knobs[i].read();
    if(dir) {
    if(dir > 0) {
    Serial.println("right");
    }
    else {
    Serial.println("left");
    }
    }
    }
    }

No public wish lists :(