Carthaginian
Member
I've been trying to read changes from a simple rotary encoder. I've connected the encoder's two pins to pins 14 and 16 on the Teensy 3. There is also a third pin on the encoder. I am under the impression that the first two pins handle the encoder portion while the third pin handles the button (there is also button mechanism). This doesn't make sense to me though since: doesn't a button require two pins? (I'm rather new to electronics and might be wrong)
I've tried several combinations of connecting these pins, but I've never gotten a value change from the read function. I've even tried connecting the third pin to ground with the "main" two at 14 and 16.
Two related questions:
I didn't use any resistors when connecting the encoder, could I have damaged it?
Why does the tutorial for the encoder library say, "Low cost encoders only connect their pins to ground. Encoder will activate the on-chip pullup resistors" ?
The schematic for the encoder is here: http://media.digikey.com/pdf/Data Sheets/Panasonic Electric Works PDFs/EVQWK.pdf
My code (only slightly modified from the example):
I've tried several combinations of connecting these pins, but I've never gotten a value change from the read function. I've even tried connecting the third pin to ground with the "main" two at 14 and 16.
Two related questions:
I didn't use any resistors when connecting the encoder, could I have damaged it?
Why does the tutorial for the encoder library say, "Low cost encoders only connect their pins to ground. Encoder will activate the on-chip pullup resistors" ?
The schematic for the encoder is here: http://media.digikey.com/pdf/Data Sheets/Panasonic Electric Works PDFs/EVQWK.pdf
My code (only slightly modified from the example):
Code:
#include <Encoder.h>
Encoder knobLeft(14, 16);
void setup() {
Serial.begin(9600);
Serial.println("TwoKnobs Encoder Test:");
}
long positionLeft = -999;
void loop() {
long newLeft;
newLeft = knobLeft.read();
//Serial.println(newLeft);
if (newLeft != positionLeft) {
Serial.print("Left = ");
Serial.print(newLeft);
positionLeft = newLeft;
}
// if a character is sent from the serial monitor,
// reset both back to zero.
if (Serial.available()) {
Serial.read();
Serial.println("Reset both knobs to zero");
knobLeft.write(0);
}
}
Last edited: