error: 'lcd' was not declared in this scope

Hello. Can somebody help me???

Code:

// include the library code #include 
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// initialize our variables
int sensorPin = 0;
int tempC, tempF;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop() {
tempC = get_temperature(sensorPin);
tempF = celsius_to_fahrenheit(tempC);
lcd.setCursor(0,0);
lcd.print(tempF); lcd.print(" "); lcd.print((char)223); lcd.print("F");
delay(200);
}
int get_temperature(int pin) {
// We need to tell the function which pin the sensor is hooked up to. We're using
// the variable pin for that above
// Read the value on that pin
int temperature = analogRead(pin);
// Calculate the temperature based on the reading and send that value back
float voltage = temperature * 5.0;
voltage = voltage / 1024.0;
return ((voltage - 0.5) * 100);
}
int celsius_to_fahrenheit(int temp) {
return (temp * 9 / 5) + 32;
}

#include <LiquidCrystal.h>         
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //Digital pins to which you connect the LCD
const int inPin = 0;                   // A0 is where you connect the sensor
void setup()
{
 lcd.begin(16,2);
}
void loop()
{
 int value = analogRead(inPin); // read the value from the sensor
 lcd.setCursor(0,1);
 float millivolts = (value / 1024.0) * 5000; 
 float celsius = millivolts / 10;
 lcd.clear();
 lcd.setCursor(0,0);
 lcd.print(celsius);
 lcd.print("C");
 lcd.setCursor(0,1);
 lcd.print((celsius * 9)/5 + 32); //turning the celsius into fahrehait
 lcd.print("F");
 delay(1000);
}

My problem:

Arduino: 1.8.10 Hourly Build 2019/05/07 05:33 (Windows 10), Board: "Arduino/Genuino Uno"

sketch_may15a:3:1: error: 'LiquidCrystal' does not name a type

C:\Users\Ričardas\Desktop\sketch_may15a\sketch_may15a.ino: In function 'void setup()':

sketch_may15a:9:1: error: 'lcd' was not declared in this scope

C:\Users\Ričardas\Desktop\sketch_may15a\sketch_may15a.ino: In function 'void loop()':

sketch_may15a:14:1: error: 'lcd' was not declared in this scope

C:\Users\Ričardas\Desktop\sketch_may15a\sketch_may15a.ino: In function 'void setup()':

sketch_may15a:35:6: error: redefinition of 'void setup()'

C:\Users\Ričardas\Desktop\sketch_may15a\sketch_may15a.ino:7:6: note: 'void setup()' previously defined here

C:\Users\Ričardas\Desktop\sketch_may15a\sketch_may15a.ino: In function 'void loop()':

sketch_may15a:39:6: error: redefinition of 'void loop()'

C:\Users\Ričardas\Desktop\sketch_may15a\sketch_may15a.ino:11:6: note: 'void loop()' previously defined here

exit status 1
'LiquidCrystal' does not name a type

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Your code is missing a #include of an appropriate LCD library

Also missing code tags.

Just write of the begging of the code: #include <LiquidCrystal.h> ?
What do you mean by code tags?

How to use this forum-please read. See #7.

groundFungus:
How to use this forum-please read. See #7.

Thanks :slight_smile:

You have two separate sketches, one after the other in your code. You can't do that. You can only have one setup() and one loop(). You need to remove one of the sketches.

tigras13577:
Just write of the begging of the code: #include <LiquidCrystal.h> ?

The first sketch is missing the #include directive for the library, so yes you do need to do that. The second sketch does have the necessary #include directive already.