'liquidCrystal_I2C' does not name a type. I'm using Arduino mega

the error i keep facing is Compilation error: 'liquidCrystal_I2C' does not name a type; did you mean 'LiquidCrystal_h'?
Here is my code
#include <LiquidCrystal.h>
//include libraries
#include <Servo.h>
#include <Wire.h>

//declare servo motor using Servo library
Servo servoClaw;

//declare liquid crystal lcd
liquidCrystal_I2C lcd(0x27, 20, 4);

//Special byte characters for loading bar lcd
byte one[] = {
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000
};

byte two[] = {
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000
};

byte three[] = {
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100
};

byte four[] = {
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110
};

byte five[] = {
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111
};

byte bottom[] = {
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B11111
};

byte top[] = {
B11111,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000
};

//pin assignment variables
int clawPin = 5;
int clawUp = 26;
int clawDown = 27;
int clawClose = 28;
int clawOpen = 29;

int clawStart = 30;
int servoRelay = 53;
int gameModePin = 16;

int xStepPin = 11;
int xDirPin = 10;
int y1StepPin = 9;
int y1DirPin = 8;
int y2StepPin = 7;
int y2DirPin = 6;
int zStepPin = 13;
int zDirPin = 12;
int stepperEnable = 52;

int xMinLmtSwtch = 15;
int xMaxLmtSwtch = 14;
int yMinLmtSwtch = 3;
int yMaxLmtSwtch = 2;
int zMaxLmtSwtch = 4;

int forwardJoystick = 23;
int backwardJoystick = 22;
int leftJoystick = 25;
int rightJoystick = 24;

int potPin = A12; //TODO: FIND ANALONG PIN

//loading bar variables
int barWidth = 20;

void pinAssign(){
pinMode(xStepPin, OUTPUT);
pinMode(xDirPin, OUTPUT);
pinMode(y1StepPin, OUTPUT);
pinMode(y1DirPin, OUTPUT);
pinMode(y2StepPin, OUTPUT);
pinMode(y2DirPin, OUTPUT);
pinMode(zStepPin, OUTPUT);
pinMode(zDirPin, OUTPUT);

pinMode(stepperEnable, OUTPUT);

pinMode(servoRelay, OUTPUT);
servoClaw.attach(clawPin);

pinMode(xMinLmtSwtch, INPUT_PULLUP);
pinMode(xMaxLmtSwtch, INPUT_PULLUP);
pinMode(yMinLmtSwtch, INPUT_PULLUP);
pinMode(yMaxLmtSwtch, INPUT_PULLUP);
pinMode(zMaxLmtSwtch, INPUT_PULLUP);

pinMode(clawUp, INPUT_PULLUP);
pinMode(clawDown, INPUT_PULLUP);
pinMode(clawOpen, INPUT_PULLUP);
pinMode(clawClose, INPUT_PULLUP);
pinMode(forwardJoystick, INPUT_PULLUP);
pinMode(backwardJoystick, INPUT_PULLUP);
pinMode(leftJoystick, INPUT_PULLUP);
pinMode(rightJoystick, INPUT_PULLUP);

pinMode(gameModePin, INPUT_PULLUP);
pinMode(clawStart, INPUT_PULLUP);

pinMode(potPin, INPUT);

}

//write default to LCD when game is off
void lcdWriteDefault(){
lcd.clear();
lcd.setCursor(0,0);
if (arcadeMode) { lcd.print("ARCADE MODE!"); }
else { lcd.print("~~FULL CONTROL!~"); }
lcd.setCursor(0,1);
lcd.print("PRESS GREEN BUTTON");
lcd.setCursor(0,3);
lcd.print("you have");
lcd.setCursor(9,3);
lcd.print(gameTimeS);
lcd.setCursor(12,3);
lcd.print("seconds");
}

//setup the LCD display
void lcdSetup(){
lcd.begin();
lcd.createChar(1, one);
lcd.createChar(2, two);
lcd.createChar(3, three);
lcd.createChar(4, four);
lcd.createChar(5, five);
lcd.createChar(6, top);
lcd.createChar(7, bottom);
lcd.backlight();
lcdWriteDefault();
}

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Please post your sketch, using code tags when you do. This prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

#include <LiquidCrystal.h>

You have #included this library but then you do this

liquidCrystal_I2C lcd(0x27, 20, 4);

Note the different name of the library

What type of interface does your LCD display use ?
Is it I2C or not ?

1 Like

You are using LiquidCrystal. h library, but you code try use LiquidCrystal_I2C instructions.
Change your library to LiquidCrystal_I2C.h library.

1 Like

OH MY GOD THANKYOU!!! I was scratching my head wondering where I was going wrong turns out it was just a simple overlook. Thankyou so much

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