Here is what I have so far. Also something I noticed is the encoder has a LED on it that blinks, when the light is broken, and when I have it connected the light constantly stays light even when the light is broken.
#include <PID_v1.h>
#define DIRA 12 // Direction
#define PWMA 3 //Motor Connected to Pin 3
#define FB 0 // Encoder Feedback to Pin 0
double Setpoint, Input, Output;
//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint,2,5,1, DIRECT);
void setup()
{
pinMode(DIRA, OUTPUT);
pinMode(PWMA, OUTPUT);
pinMode(FB, INPUT);
//initialize the variables we're linked to
Input = analogRead(0);
Setpoint = 200;
//turn the PID on
myPID.SetMode(AUTOMATIC);
}
void loop()
{
Input = analogRead(0);
myPID.Compute();
analogWrite(PWMA, Output);
digitalWrite(DIRA, LOW);
}