I wrote a simple code to count the number of pulses when the motor runs.
The code just counts the number of interrupts from the encoder, but the output is very weird.
Even when the motor is not running it outputs huge numbers of the range of 10000s as the number of pulses.
Same case with the other motor.
Is something wrong with the encoders or am i missing something?
{}
button to give it the correct formatting.digitalPinToInterrupt(pin)
instead of directly passing the interrupt number (0 should be correct, though). The reason for those readings you get when the motor isn‘t running could be that the interrupt pin is floating. TrypinMode(encoder_in, INPUT_PULLUP);
.