Trouble with encoder

Hi I just picked up three rotary encoders from adafruit and they are unresponsive with the nkrkv/encoder node. The node deploys but the counters don’t move when handling the encoder. Has anyone else had this issue lately? Could it be these particular encoders? All my pins are set up properly so im not sure what the issue could be.

These are the encoders: https://www.adafruit.com/product/377

This is the node code that im trying to use. It is directly from the example experiment from the nkrkv/encoder library.

Thanks!

Hmm… They should. The library is made specifically for this kind of encoders. Are you sure your wiring is correct? Do you see digital port value switching if use a pair of simple xod/gpio/digital-read?

1 Like

Thanks for your response! Checked the wiring and seems ok. Digital read pins both say “false” and don’t switch when I rotate the encoder. Oddly, I can get the encoder working in one direction with the escape-ford / encoder ky040 node. Very strange!

1 Like

I think your encoder needs pull-up resistors.
in the example of arduino the pull-ups are configured, but in XOD they are not implemented, you can put external resistors or modify the code C++

void setup()
{
  // set pins as input with internal pull-up resistors enabled
  pinMode(PIN_ENCODER_A, INPUT_PULLUP);
  pinMode(PIN_ENCODER_B, INPUT_PULLUP);
  pinMode(PIN_ENCODER_SWITCH, INPUT_PULLUP);
3 Likes

@cesars Yes!! Thank you! Just added some 1k pull ups and works perfectly!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.