×

SparkFun Electronics will be closed in observance of memorial day on Monday, May 29th. We will resume normal business hours on Tuesday, May 30th. Any orders placed after 2pm Mountain Time on Friday, May 26th will process and ship out on Tuesday, May 30th.

avatar

Member #270191

Member Since: November 28, 2011

Country: United States

Profile

Master’s Candidate Interactive Telecommunications Program NYU // TISCH

  • Thanks for the start, @Ocean\ Controls! Here’s a full Arduino sketch with wiring instructions in the comments header.

    /*  YUMO rotary encoder
     *  
     *  Wiring
     *  Black - pin 2
     *  White - pin 3
     *  Brown - Ard. 5V
     *  Blue  - GND
     *  Orange - nothing for this use (is possibly for dir encoding?). 
     */
    
    
    
    long encoder = 0; // counts overall number of 'ticks' since beginning of program
    const int encoder_a = 2; // black 
    const int encoder_b = 3; // white 
    
    void setup() {
      Serial.begin(9600);
      pinMode(encoder_a, INPUT);
      pinMode(encoder_b, INPUT);
    
      // encoder pin on interrupt 0 (pin 2)
      attachInterrupt(0, encoderPinChangeA, CHANGE);
      // encoder pin on interrupt 1 (pin 3)
      attachInterrupt(1, encoderPinChangeB, CHANGE);
    }
    
    void loop() {
      Serial.println(encoder);
    }
    
    
    void encoderPinChangeA() {
     if (digitalRead(encoder_a)==digitalRead(encoder_b)) {
      encoder--;
     }
     else{
      encoder++;
     }
    }
    
    void encoderPinChangeB() {
     if (digitalRead(encoder_a) != digitalRead(encoder_b)) {
      encoder--;
     }
     else {
      encoder++;
     }
    }
    
  • Found this: http://www.hazelwoodsound.com/motorized-faders-and-the-arduino/

    You can find more results by searching for “motorized fader,” as it seems the most popular application of this component is with audio mixers.

  • +1 for example wiring and code.

  • The motor_go function is a bit confusing, particularly the relationship between the step size and increment values. I keep getting an error in my Serial Window that reads “incorrect value for motor_go().” What is causing this? I don’t see anything in the forums on this question.

  • Found the problem. In the .cpp and .h file included in the library, you need to change

    #include "WProgram.h"
    

    to ->

    #include "Arduino.h"
    

    This is if you’re running 1.0.1. Not sure about other versions. This will also be true for any library written before this change in the Arduino software.

  • Udpate: solved one problem, have new one. The prior error was due to running the code and its libraries from inside a Dropbox folder. That’s a no-no. I moved everything into the Documents > Arduino > Libraries folder and compiled and get a new error: “ Error Compiling: In file included from quad_step_test.cpp:43: /Users/matthewepler/Documents/Arduino/libraries/quadstep/quadstep.h:12:22: error: WProgram.h: No such file or directory”

    Clues? -M

  • Is anyone else having trouble compiling the example in the library? I’m getting a definition/class error: ‘quadstep does not name a type.’ No changes were made to the Example and it’s in the right place. -M

No public wish lists :(