Why 'LCD' was not declared in this scope

// AC Current Sensor with LCD By Solarduino
 
// 0- General
 
int decimalPrecision = 2;
 
// 1- AC Current Measurement
 
int CurrentAnalogInputPin = A1;
float mVperAmpValue = 185;
 
float offsetSampleRead = 0;
float currentSampleRead = 0;
float currentLastSample = 0;
float currentSampleSum = 0;
float currentSampleCount = 0;
float currentMean ;
float RMSCurrentMean ;
float adjustRMSCurrentMean ;
float FinalRMSCurrent ;
 
//1.1 Offset AC Current
 
int OffsetRead = 0;
float currentOffset1 = 0;
float currentOffset2 = 0;
float offsetSampleSum =0;
float offsetCurrentMean = 0;
float offsetLastSample = 0;
float offsetSampleCount = 0;
 
//2 - LCD Display
 
#include <LiquidCrystal.h> LCD(8,9,4,5,6,7);
unsigned long startMillisLCD;
unsigned long currentMillisLCD;
const unsigned long periodLCD = 1000;
 
void setup()
 
{
 
// 0- General
 
Serial.begin(9600);
 
// 2 - LCD Display
 
LCD.begin(16,2);
LCD.setCursor(0,0);
startMillisLCD = millis();
 
}
 
void loop()
{
 
// 0- General
 
// 0.1- Button Function
 
int buttonRead;
buttonRead = analogRead (0);
 
//Right button is pressed
if (buttonRead &lt; 60)
{ LCD.setCursor(0,0); LCD.print ("PRESS<select>"); }</select>
 
// Up button is pressed
else if (buttonRead &lt; 200)
{ LCD.setCursor(0,0); LCD.print ("PRESS<select>"); }</select>
 
// Down button is pressed
else if (buttonRead &lt; 400)
{ LCD.setCursor(0,0); LCD.print ("PRESS<select>"); }</select>
 
// Left button is pressed
else if (buttonRead &lt; 600)
{ LCD.setCursor(0,0); LCD.print ("PRESS<select>"); }</select>
 
// Select button is pressed
else if (buttonRead &lt; 800) { OffsetRead = 1; LCD.setCursor(0,0); LCD.print ("INITIALIZING..... "); LCD.setCursor(0,1); LCD.print ("WAIT 5 SEC ..... "); } // 1- AC Current Measurement if(millis() &gt;= currentLastSample + 1)
{
offsetSampleRead = analogRead(CurrentAnalogInputPin)-512;
offsetSampleSum = offsetSampleSum + offsetSampleRead;
 
currentSampleRead = analogRead(CurrentAnalogInputPin)-512 + currentOffset1;
currentSampleSum = currentSampleSum + sq(currentSampleRead) ;
 
currentSampleCount = currentSampleCount + 1;
currentLastSample = millis();
}
 
if(currentSampleCount == 1000)
{
offsetCurrentMean = offsetSampleSum /currentSampleCount;
 
currentMean = currentSampleSum/currentSampleCount;
RMSCurrentMean = sqrt(currentMean);
adjustRMSCurrentMean = RMSCurrentMean + currentOffset2;
FinalRMSCurrent = (((adjustRMSCurrentMean /1024) *5000) /mVperAmpValue);
Serial.print(" The Current RMS value is: ");
Serial.print(FinalRMSCurrent,decimalPrecision);
Serial.println(" A ");
offsetSampleSum = 0;
currentSampleSum =0;
currentSampleCount=0;
}
 
//1.1 - Offset AC Current
 
if(OffsetRead == 1)
{
currentOffset1 = 0;
if(millis()&gt;= offsetLastSample + 1)
{
offsetSampleCount = offsetSampleCount + 1;
offsetLastSample = millis();
}
if(offsetSampleCount == 1500)
{
currentOffset1 = - offsetCurrentMean;
OffsetRead = 2;
offsetSampleCount = 0;
}
}
 
if(OffsetRead == 2)
{
currentOffset2 = 0;
if(millis()&gt;= offsetLastSample + 1)
{
offsetSampleCount = offsetSampleCount + 1;
offsetLastSample = millis();
}
 
if(offsetSampleCount == 2500)
{
currentOffset2 = - RMSCurrentMean;
OffsetRead = 0;
offsetSampleCount = 0;
}
}
 
// 2 - LCD Display
 
currentMillisLCD = millis();
if (currentMillisLCD - startMillisLCD &gt;= periodLCD)
{
LCD.setCursor(0,0);
LCD.print("I=");
LCD.print(FinalRMSCurrent,decimalPrecision);
LCD.print("A                   ");
LCD.setCursor(0,1);
LCD.print("                      ");
startMillisLCD = currentMillisLCD ;
}
 
}
``` whys it that im getting that error

i dont know why im getting 'LCD' was not declared in this scope
error

Hello Swagometer, Good day.
check the example:
https://www.arduino.cc/reference/en/libraries/liquidcrystal/liquidcrystal/

Example

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

void setup()
{
  lcd.begin(16,1);
  lcd.print("hello, world!");
}

void loop() {}

Best regards
Markus

What do you think this line does?

@swagometer, welcome and thanks for using code tags in your first post.

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.