Encoders and PWM for PID control

Hi! I'm trying to use the basic example for the PID library.

I would like to get my robot to move straighter based on the encoder values. I currently have two encoders measuring the back left and right wheels. Could someone help me out by implementing the following:

//Define Variables we'll be connecting to
double Setpoint, Input, Output;

//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint,2,5,1, DIRECT);

void setup()
  //initialize the variables we're linked to
  Input = analogRead(0);
  Setpoint = 100;

  //turn the PID on

void loop()
  Input = analogRead(0);

The problem I'm having is that my input is a digital value that I'm counting from the encoders called (counterLeft and counterRight)

You can use the encoder count difference for Input, and adjust one of the motor's speed using Output.

You should understand that a PID inputs a single signal, and produces a single output value. You have to decide yourself, what shall be used for the input and output signals, and of course you have to adjust the PID for handling your device properly.

Perhaps you better start with a single motor, and try to stabilize its speed by a PID?

How would I get the feedback though? I can only write the PWM output.

I apologize i misread your question. Ok I will try thank you! Also should it be a problem that the encoders are digital inputs?

A PID works on digital numbers, no matter whether these originate from an ADC or other source.

If I let my input be the difference between counters, which will usually be in the range of 4 or 5 max. There difference will be very low. So I'm confused on how to apply this. My output is just the PWM output to the motor which i usually want around 100.

Why do you have two threads on the same problem?
That is frowned upon in this forum.

I'm getting extremely stressed out and I cannot find any help. All I'm trying to do is get my robot to go straight. I cannot find any good examples that take in digital inputs from encoders and control the output to the PWM. I apologize for the multiple thread. Its been a rough day.