Rotary Encoder and Stepper motor

Is your encoder on the output shaft of the stepper motor, and fixed to the shaft? Or is it fixed somewhere else?

Assuming the encoder is separate, you need to use the encoder to adjust the value of a variable which represents the desired position of the motor. So if you move the encoder +4 the motor position variable might change from 377 to 381 and if you move the encoder -4 the variable will go back to 377.

Then your motor movement function needs to read that position and move the motor it by stepping forwards or backwards by the appropriate number of steps.

...R