Only one ecnoder using Arduino Nano

We are using only one encoder with an Arduino Nano in our design.

The following example code gives us an error if we initialize only 2 lines.

#include <PololuWheelEncoders.h>

void setup() {
  PololuWheelEncoders::init(2,4,8,7);
}

int one = 0;
int two = 1;

void loop() {
  Serial.println(PololuWheelEncoders::getCountsM1());
  Serial.println(PololuWheelEncoders::getCountsM2());

  delay(1000);
}

The error is:

ADC_PWM.ino: In function 'void setup()':
ADC_PWM:53: error: no matching function for call to 'PololuWheelEncoders::init(int, int)

The function is looking for 4 I/O’s to be initialized.

To get over this problem we initialized the same lines twice.

#include <PololuWheelEncoders.h>

void setup() {
  PololuWheelEncoders::init(9,12,9,12);
}

Will this work?

Is there any other way around this?

We are out of GPIO’s and cannot blank initialize any I/O’s.
Please let us know if there is a solution around this or if there is a version of a modified library somewhere.

Hello.

I have moved your post into its own thread.

Which Pololu encoder are you using? You might try passing a pin number that does not exist, such as 255, to the extra two pins. If this does not work, you might consider trying an Arduino encoder library like this “Encoder Library” that supports using a single encoder.

-Brandon