How Can I Solved This Error In My Arduino Program

#include <PID_v1.h>
//Define Variables we'll be connecting to
double Setpoint, Input, Output;
//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint,5,2,1, DIRECT); // 1
int potPin = A2; // select the input pin for the potentiometer
int pot = 0; // it starts as O but it's not necessary to define it, it doesn't change anything
int dir2B= 12; // Motor direction
int enableM2 = 10; // Motor enabling
void setup () // definine inputs and outputs
{
Serial.begin(9600);
pinMode(potPin, INPUT); // we define the potentiometer input
pinMode(dir2B, OUTPUT); // set the motor pins as outputs:
pinMode(enableM2, OUTPUT); // set the motor pins as outputs:
digitalWrite(enableM2, HIGH); // set enablePins high so that motor can turn on:
//initialize the variables we're linked to
Input = analogRead(potPin);
Setpoint = 586;
//turn the PID on
myPID.SetMode(AUTOMATIC);
}
void loop ()
{
pot= analogRead(potPin); // read the value of the potentiometer
Input = pot;
myPID.Compute();
int error=(586-pot); // reference=586, measured=pot
int vel=255;
if (-190 < error && error < 0) // if the value of the potentiometer is between -190 and 0 degrees:
{
digitalWrite(dir2B, HIGH);
analogWrite(enableM2,(255-Output));
Serial.println(255-Output);
}
if (190 > error && error > 0) // if the value of the potentiometer is between 190 and 0 degrees:
{
digitalWrite(dir2B, LOW);
analogWrite(enableM2,Output);
Serial.println(Output);
}
if (error < -190 || error > 190) // if the value of the potentiometer is less than -190 or more than 190 degrees:
{
digitalWrite(enableM2, LOW);
}
}

Errors:

C:\Users\Partha\Documents\Arduino\libraries\PID_v1\PID_v1.cpp: In constructor 'PID::PID(double*, double*, double*, double, double, double, int)':
C:\Users\Partha\Documents\Arduino\libraries\PID_v1\PID_v1.cpp:26: error: 'millis' was not declared in this scope
C:\Users\Partha\Documents\Arduino\libraries\PID_v1\PID_v1.cpp: In member function 'void PID::Compute()':
C:\Users\Partha\Documents\Arduino\libraries\PID_v1\PID_v1.cpp:43: error: 'millis' was not declared in this scope

If anyone can solve those Errors..Plss Tell me as soon as possible...

Your error is here:

C:\Users\Partha\Documents\Arduino\libraries\PID_v1\PID_v1.cpp

If you can show us that file, plus the .h file, then we might have a better chance of finding it.

Please use [code][/code] tags.

Here is the file...Hope it is enough for u.... :confused:

PID_v1.zip (6.78 KB)

Hi,

this is an old library for Arduino IDE < 1.0. If you are using a newer IDE > 1.0,
you have to replace in the PID_v1.cpp file following line:

replace #include <WProgram.h>
to:
#include <Arduino.h>

That's it. It should compile.

Greetings

Just to be safe it would be better to download a fresh copy of PID_v1 which has the updates already applied:
https://github.com/br3ttb/Arduino-PID-Library/zipball/master

Remember to rename the library to "PID_v1" when you install it.

Thank you sir...Now it is compiled without any error...thanks once again. #johnwasser