Search for a working scetch /DC Gear Motor / Encoder / Positioning / PID

Guess what these do!

  Timer1.setPwmDuty(outPwm, output);
  digitalWrite(outDir, dir);

The output of the PID is driving direction and PWM pins at the end of doPID.
If you've got two pins for direction its simple to extend this!