Rotary Encoder on Teensy LC only outputting "0" or "-1"

Status
Not open for further replies.

bcnx

Active member
Hi all,

I connected a rotary encoder with the classic 5 pin layout (3 pins for the rotary part, 2 pins for the switch) to a Teensy LC. I'm using pin 2 on the LC for the switch and pin 3 and 4 for the rotary encoder. I connected the pins directly, no pull-up resistors.
Next, I used the code on https://www.pjrc.com/teensy/td_libs_Encoder.html
Where this code seems to output values ranging from -3 to 8, I only get 0 and -1. If the value is on 0 and I turn CW, I get -1 and if I turn CCW from 0, I get also -1.
I found https://forum.pjrc.com/threads/35879-MIDI-Controller-using-16-Rotary-Encoders, where some guy has 0 and 1 values, and someone else in that post says this is normal.
What am I doing wrong?
I did read that there are analogue and digital rotary encoders - I suppose I have a digital one, as I get alternating connectivity and disconnectivity between the outer pins and ground.

cheers,

BC
 
Last edited:
Sounds like the wires aren't connected the right way. This is one of the pretty well known results where only 1 of the signals is really working.
 
Hi Paul, great seeing you again.
I double checked and they seem OK. I exchanged the rotary pins, but that gives me -1 and -2 values.
I use pins 3 and 4 for the encoder as they are INT pins. Should I use different ones?
 
Pins 3 and 4 are fine.

I recommend using a voltmeter to watch the actual voltage on each pin as you very slowly move the encoder.
 
That was a genious tip. I had alternating 3.3 volts on the left pin, but a steady 3.3 volts on the right pin. Turns out this pin was not seated properly in my breadboard. I had checked that before, but it must have gotten out while manipulating the board.
Thanks a mille, Paul, I thought I did something wrong. Well, errr, I kinda did...
 
Status
Not open for further replies.
Back
Top