if (result == DIR_CW) {
counter++;
Serial.println(counter);
} else if (result == DIR_CCW) {
counter--;
Serial.println(counter
Don't use Serial.print within an ISR. Set a flag to be acted upon in the main code.
if (result == DIR_CW) {
counter++;
Serial.println(counter);
} else if (result == DIR_CCW) {
counter--;
Serial.println(counter
Don't use Serial.print within an ISR. Set a flag to be acted upon in the main code.