User:1sfoerster/enes100/Tri-BotHack/Encoder1

/* Encoder Library - Basic Example * http://www.pjrc.com/teensy/td_libs_Encoder.html * * This example code is in the public domain. */


 * 1) include 

// Change these two numbers to the pins connected to your encoder. //  Best Performance: both pins have interrupt capability //  Good Performance: only the first pin has interrupt capability //  Low Performance:  neither pin has interrupt capability Encoder myEnc(2, 3); // 3 and 2 go to the motor 1 and 2 encoders //  avoid using pins with LEDs attached // initialize the motor control output button

void setup { Serial.begin(9600); Serial.println("Basic Encoder Test:"); pinMode(11, OUTPUT); //yellow wire to motor enable 1 digitalWrite(11, HIGH); //turn on motor 1

}

long oldPosition = -999;

void loop { long newPosition = myEnc.read; if (newPosition != oldPosition) { oldPosition = newPosition; Serial.println(newPosition); } }