You have an unusual motor controller. The motor only runs when the two inputs are different. Usually there would be one input for Direction and one for Speed. The way yours works, the Speed goes from 0 to 255 (off to full) on one direction and 255 to 0 (off to full) in the other direction.
// Motor control 1 is connected to the Digital PIN 5
const int MotorControlPin1 = 5;
// Motor control 2 is connected to the Digital PIN 6
const int MotorControlPin2 = 6;
void loop(){
Input = encoder0Pos;
myPID.Compute();
if (Output > 0)
{
// Output is positive so set MotorControlPin2 (Direction) to HIGH
digitalWrite(MotorControlPin2, HIGH);
// When Direction is HIGH, a LOW on MotorControlPin1 (PWM Speed) causes the motor to run
analogWrite(MotorControlPin1, 255 - constrain((int)Output, 0, 255));
}
else
{
// Output is negative so set MotorControlPin2 (Direction) to LOW
digitalWrite(MotorControlPin2, LOW);
// When Direction is LOW, a HIGH on MotorControlPin1 (PWM Speed) causes the motor to run
analogWrite(MotorControlPin1, constrain((int)-Output, 0, 255));
}
}