Nano + rotary encoder

There seem to be specific pins to connect encoders to Arduino NANO. In most library examples pins A2 and A3 are used. All examples work for me. When I connect The encoder to A6 and A7 (and adjust the sketch) it doesn't work.
A3+A4 work
A4+A5 work,
A5+A6 only counts down (even with reversed CLK en Data)
if A7 is involved : nothing works ...

Library used : RotaryEncoder.h
I can't find an explanation for this issue... Aren't all inputs(A0...A7) the same ???
Thanks in advance !


// Setup a RoraryEncoder for pins A2 and A3:
RotaryEncoder encoder(A2, A3);

void setup()
{
  Serial.begin(57600);
  Serial.println("SimplePollRotator example for the RotaryEncoder library.");
} // setup()


// Read the current position of the encoder and print out when changed.
void loop()
{
  static int pos = 0;
  encoder.tick();

  int newPos = encoder.getPosition();
  if (pos != newPos) {
    Serial.print(newPos);
    Serial.println();
    pos = newPos;
  } // if
} // loop ()

No - A6 and A7 are analogue only.

That surprises me - I can understand using 2 & 3 because they are external interrupt pins.

There aren't. Any pin will do, except, as you noticed, A6 & A7.
The exception is if you use a library that relies on INT0 and INT1, in which case you're stuck with pins D2 and D3 exclusively. I'm not aware of any rotary library that is silly enough to rely on INT0 and INT1 though. Insofar as they're interrupt driven (which they usually don't even need to be), they tend to use the general pin change interrupts.

Thanks for your replies, guys !
I checked the library files, and there is no talking about interrupts. (The sketch is named "SimplePollRotator.ino" So indeed POLL, not INTERRUPT.
but I think I'll have to go for the answer of TheMember... If A6-A7 are exclusively Analog, then I'll have to redraw my circuit board :frowning: and juggle around other "analog inputs" :slight_smile:

long THANKS!

Uhmm, no:

char t[] = "Thanks";

:wink:

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