PID does not name a type

I know this is a duplicate thread, but the initial thread did not answer my question.

i’ve tried the ff. things:

rename zip file to PID_v1
extract zip file and rename to PID_v1
but it still won’t recognize PID

here’s my code

#include <PID_v1.h>
double Setpoint, Input, Output;
const int trigger=6;
const int echo=7;
float distance;
char buffer[50];
int i=0;

PID myPID(&Input, &Output, &Setpoint,2,5,1, DIRECT);

void setup(){
Serial.begin(9600);
pinMode(trigger,OUTPUT);
pinMode(echo,INPUT);
Input=distance;
myPID.setMode(AUTOMATIC);
Setpoint=2;
}

void loop(){
invokesensor();
myPID.Compute();
Input=distance;
i=sprintf(buffer,"%d %d", Input,Output);
for(int I=0;I<=i;I++)
Serial.print(buffer*);*
}
void invokesensor(){

  • // Trigger US-100 to start measurement*
    // Set up trigger
    digitalWrite(trigger,LOW);
    delayMicroseconds(5);
    // Start Measurement
    digitalWrite(trigger,HIGH);
    delayMicroseconds(10);
    digitalWrite(trigger,LOW);
    // Acquire and convert to mtrs
    distance=pulseIn(echo,HIGH);
    distance=distance*0.0001657;
    // send result to UART
    delay(50);
    }

When I try to compile your code I get a different error:

sketch_aug10a.ino: In function 'void setup()': sketch_aug10a:16: error: 'class PID' has no member named 'setMode'

The "does not name a type" error usually means it was unable to find the include file. Do you get a 'File not found" error as well?