Error in using the encoder 30rpm pololu d.c geared motor

Recently, I brought a N20 6V 30rpm pololu dc geared motor from here-

And to test the encoder I used the code from this link of the same website.

The issue is, the encoder value just keeps oscillating between 0 & 1 . It neither decreases or increases in response to manually rotating the encoder wheel or programatically rotating the motor.

I have warped around this issue for days now. Am I missing any detail here?


Since it seems you are using an Arduino, you should try one of the Arduino rotary encoder libraries that support interrupts to see if they can work for you.

If you continue to have problems, you should contact the manufacturer of those motors for further help.