'lcd' was not declared in this scope

Hi there,

The title sums it up, I tried updating the libraries, and using LCD.h, LiquidCrystal.h, NewLiquidCrystal.h without success. Any idea what I might be doing wrong?

///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// PWM CONTROL HEATER ///////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

          //    Libraries   //
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

          //    Variables   //
    const int analogInPin1 = A1;      // Timer Pot
    const int analogInPin = A0;       // Duty Cycle Pot
    const int Heater1 = 9;            // Analog output pin that the Heater is attached to
    const int Heater2 = 10;           // Analog output pin that the Heater is attached to

    float Temp = 0;                   // value read from the pot
    float Time = 0;
    float var = 0;
    float var1 = 0;
    float outputValue = 0;            // value output to the PWM (analog out)
    float dc =0;;

          //  Button Settings
    float pressLength = 0;            //This value will be recorded in seconds
    int presstime = 100;              //Time pressing the button
    int buttonPin = 2;                //Button Pin

          //  LCD Screen Settings
    #define BACKLIGHT_PIN     13

void setup() {

          //  Switch on the backlight
    pinMode ( BACKLIGHT_PIN, OUTPUT );
    digitalWrite ( BACKLIGHT_PIN, HIGH );
    pinMode(buttonPin, INPUT_PULLUP);  
    Serial.begin(9600);
    lcd.begin(16,4);               // initialize the lcd 
}

void loop() {

          //    Duty Cycle Setting    //
    Temp = analogRead(analogInPin);             // read the analog in value
    outputValue = map(Temp, 0, 1023, 0, 100);   // outputValue = map(Temp, 0, 1023, 0, 255);
    dc = (outputValue/255) * 100;
   
          //    Time Setting    //
    var = analogRead(analogInPin1);
    Time = map(var,0, 1023, 300000,540000);     // entre 5 y 9 min
    var1 = map(Time,300000, 540000, 5, 9);
    
          //    Print the results to the Serial Monitor   //
    Serial.print("Minutes = ");
    Serial.print(var1);
    Serial.print("  | ");
    Serial.print("sensor =");
    Serial.print(Temp);
    Serial.print("  | ");
    Serial.print("output =");
    Serial.println(dc);

    //analogWrite(Heater1, outputValue);
    //analogWrite(Heater2, outputValue);

          //    LCD Settings    //
    lcd.begin(16,4);               // initialize the lcd 
    lcd.home ();                   // go home
    lcd.print("Minutes: ");
    lcd.print(var1);  
    lcd.setCursor ( 0, 1 );        // go to the next line
    lcd.print("Duty Cycle: ");
    lcd.print(dc);
    

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
          //    Press button    //
    while (digitalRead(buttonPin) == LOW ){     //Record *roughly* the tenths of seconds the button in being held down
      delay(100);                                 //if you want more resolution, lower this number 
      pressLength = pressLength + 100;   
  
    } //close while

    if (pressLength >= presstime){
        int startTime = millis();
        int endTime = startTime - Time;
          
          while(millis()<endTime){
            analogWrite(Heater1, outputValue);
            analogWrite(Heater2, outputValue);
          
    }
  } 
  delay(2);
}

I can't see where you've defined an lcd object.
The compiler can't either.

Ha! not a small detail.

now my problem is that I don’t get anything on the screen. I run a scanner and the address is right.

New Code:

///////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// PWM CONTROL HEATER ///////////////////////////////
///////////////////////////////////////////////////////////////////////////////////

          //    Libraries   //
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

          //    Variables   //
    const int analogInPin1 = A1;      // Timer Pot
    const int analogInPin = A0;       // Duty Cycle Pot
    const int Heater1 = 9;            // Analog output pin that the Heater is attached to
    const int Heater2 = 10;           // Analog output pin that the Heater is attached to

    float Temp = 0;                   // value read from the pot
    float Time = 0;
    float var = 0;
    float var1 = 0;
    float outputValue = 0;            // value output to the PWM (analog out)
    float dc =0;;

          //  Button Settings
    float pressLength = 0;            //This value will be recorded in seconds
    int presstime = 100;              //Time pressing the button
    int buttonPin = 2;                //Button Pin

          //  LCD Screen Settings
    #define BACKLIGHT_PIN     13
    LiquidCrystal_I2C lcd(0x27,16,2);
void setup() {

          //  Switch on the backlight
    pinMode ( BACKLIGHT_PIN, OUTPUT );
    digitalWrite ( BACKLIGHT_PIN, HIGH );
    pinMode(buttonPin, INPUT_PULLUP);  
    Serial.begin(9600);
    lcd.begin(16,2);               // initialize the lcd 
}

void loop() {

          //    Duty Cycle Setting    //
    Temp = analogRead(analogInPin);             // read the analog in value
    outputValue = map(Temp, 0, 1023, 0, 100);   // outputValue = map(Temp, 0, 1023, 0, 255);
    dc = (outputValue/255) * 100;
   
          //    Time Setting    //
    var = analogRead(analogInPin1);
    Time = map(var,0, 1023, 300000,540000);     // entre 5 y 9 min
    var1 = map(Time,300000, 540000, 5, 9);
    
          //    Print the results to the Serial Monitor   //
    Serial.print("Minutes = ");
    Serial.print(var1);
    Serial.print("  | ");
    Serial.print("sensor =");
    Serial.print(Temp);
    Serial.print("  | ");
    Serial.print("output =");
    Serial.println(dc);

    //analogWrite(Heater1, outputValue);
    //analogWrite(Heater2, outputValue);

          //    LCD Settings    //
    lcd.begin(16,2);               // initialize the lcd 
    lcd.home ();                   // go home
    lcd.print("Minutes: ");
    lcd.print(var1);  
    lcd.setCursor ( 0, 1 );        // go to the next line
    lcd.print("Duty Cycle: ");
    lcd.print(dc);
    

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
          //    Press button    //
    while (digitalRead(buttonPin) == LOW ){     //Record *roughly* the tenths of seconds the button in being held down
      delay(100);                                 //if you want more resolution, lower this number 
      pressLength = pressLength + 100;   
  
    } //close while

    if (pressLength >= presstime){
        int startTime = millis();
        int endTime = startTime - Time;
          
          while(millis()<endTime){
            analogWrite(Heater1, outputValue);
            analogWrite(Heater2, outputValue);
          
    }
  } 
  delay(2);
}

First off, please press ctrl-T before pasting code. It is the best part of the Arduino IDE.

I suggest that you install hd44780.h library via the Library Manager.
It identifies the correct slave, wiring, ...

No-one knows what "LiquidCrystal_I2C.h" you happen to have. There are several with the same class name.

David.

Have tried adjusting the contrast? I agree with david_prentice, the hd44789 library is very good. Find documentation here. The class that you should use is the hd44780_I2Cexp class.