'lcd' was not declared in this scope

Hi guys,
I have resolved this issues with following lines

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

was enought to solve POSITIVE error

Hey, I’m creating a Buzz Wire game, and I saw a simple DIY on Youtube. I got an average explanation on their website, but there is multiple problems with the code, for example, ‘lcd’ was not declared in this scope. Below is my code, I have read this thread and I cant seem to find a solution (I may be wrong.) The highlighted line of code is lcd.setCursor(0,0);

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int startPin = 2;
const int endPin = 3;
const int buzzer = 4;
int start, end_;
void setup(void)
{
Serial.begin(9600);
lcd.begin(16, 2);
lcd.clear();
pinMode(buzzer, OUTPUT);
pinMode(startPin, INPUT_PULLUP);
pinMode(startPin, INPUT_PULLUP);
}
void loop(void)
{
start = digitalRead(startPin);
end_ = digitalRead(endPin);
Serial.print(start);
Serial.print("\n");
Serial.print(end_);
if (start == LOW && end_== LOW ){
digitalWrite(buzzer, HIGH);
delay(1000);
digitalWrite(buzzer, LOW);
lcd.setCursor(0,0);
lcd.print(“Try Again”);
Serial.print(“Try Again”);
}
else if (start == HIGH && end_== LOW){
lcd.setCursor(0,0);
lcd.print(“Well Done”);
Serial.print(“Well Done”);
}
delay(500);
}

OK, so a few things here.

Is this your code, or something you obtained from the unspecified YouTube site?

The way to approach using a LCD is to start with the traditional "Hello World" test sketch. Have you done this? Presumably not. :grinning:

Our current advice here - rather than looking at a nearly four year old thread - is to install Bill Perry's "HD44780" library using the library manager in the IDE.

This generates many examples in the "examples" folder which will allow you to test your display and give you the base code with which you can construct your application more reliably than using the older libraries which as you see from the thread above, have proven just a little difficult. :roll_eyes: