Note all the comments that says
//these pins can not be changed 2/3 are special pins
And note how you have the pins defined:
int encoderPin1 = 4;
int encoderPin2 = 3;
A and B should be connected to 2 and 3, not 3 and 4.
Note all the comments that says
//these pins can not be changed 2/3 are special pins
And note how you have the pins defined:
int encoderPin1 = 4;
int encoderPin2 = 3;
A and B should be connected to 2 and 3, not 3 and 4.