/********************************************************
PID Basic Example
Reading analog input 0 to control analog PWM output 3
********************************************************/
#include <PID_v1_bc.h>
//Define Variables we'll be connecting to
double Setpoint, Input, Output;
//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint, 20, 0.2, 1, DIRECT);
void setup()
{
Serial.begin(115200);
//initialize the variables we're linked to
Input = 30;
Setpoint = 66;
//turn the PID on
myPID.SetMode(AUTOMATIC);
}
void loop()
{
myPID.Compute();
analogWrite(3, Output);
Serial.print(Input);
Serial.print(" ");
Serial.println(Output);
Input = Input + 1;
delay(100);
}