Need some help PLS!

Hello guys,
I have a motor 70:1 Metal Gearmotor 37Dx70L mm with 64 CPR Encoder, connected to a motor shield based on LN298 driver, and an Arduino Mega.
I want to track the number of revolution of the motor. According with the specification if i only use one encoder output, for one complete revolution is needed 70* 12 pulses count.
I connect the encoder output to a interrupt to Mega and count 70*12 pulses but the motor do less then ONE complete revolution. Where is the mistake?? Below is the code i use.

[code]int pinA = 2;
int numberA=0;
int MOTOR1_PIN1 = 6;
int MOTOR1_PIN2 = 9;

void setup()
pinMode(pinA, INPUT);
pinMode(pinB, INPUT);
attachInterrupt(digitalPinToInterrupt(pinA), CountA, RISING);

void loop()
if (numberA == 70*12)

void CountA()

void speed(int speedValue) {
if (speedValue > 0) {
analogWrite(MOTOR1_PIN1, speedValue);
analogWrite(MOTOR1_PIN2, 0);
else {
analogWrite(MOTOR1_PIN1, 0);
analogWrite(MOTOR1_PIN2, -speedValue);



It sounds like you are misinterpreting the specification or making an error in your calculation. The encoder gives 64 counts per revolution when counting each high and low transition from both encoders. If you use a single channel of the encoder, you should still get 32 counts per revolution. If you only increase the count on a rising edge of a single channel of the encoder (which it looks like your code is doing), this would be reduced to 16 counts per revolution.

Since the encoder is connected to the motor shaft before going through the gearbox, you can multiply the counts per revolution by the gear ratio (70 in this case) to calculate the number of pulses you should get in one revolution. We also note the counts per revolution on the #2825 gearmotor’s product page to be 4480 (when using all 64 CPR that the encoder is capable of). Since you are using only the rising edge of a single channel, it should come out to 1/4th of this, or 1120.