Pololu wheel encoders not working with Mega 2560....

Hey gang,

A buddy and I in the Atlanta Hobby Robotics Club are having an issue. We’re both using the Pololu Wheel Encoders:

Using the code attached below, we were trying to get back some values, but we’re
consistently receiving a 0 value from the encoder, when running on either of our
Arduino Mega 2560 R3 boards.

I then tried the same code hooking the encoder up to my Arduino Uno (rev2) board, and
it worked perfectly, giving back the expected values.

We’re a bit stumped. It didn’t seem to matter which pins we set the encoder’s
signal on (adjusting the code as needed). Worked on the Uno, didn’t on the Mega.

Ideas??? Is there something different about the Uno and Mega in this regard?

(This was using the latest version of the Pololu_avr_library)

Test Code:

#include <PololuWheelEncoders.h>
PololuWheelEncoders encoders;

void setup() {
Serial.begin(9600);
encoders.init(2,3,18,19);//Arduino Mega pin numbers
}

void loop() {
Serial.print(encoders.getCountsM1());
Serial.print(" ");
Serial.println(encoders.getCountsM2());
delay(1000);
}