Compilation error: expected unqualified-id before 'int'

#include <Servo.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);

Servo myservo;

#define ir_enter 2
#define ir_back 4

#define ir_car1 5
#define ir_car2 6
#define ir_car3 7
#define ir_car4 8

int S1 = 0, S2 = 0, S3 = 0, S4 = 0;
int flag1 = 0, flag2 = 0;
int slot = 4;

void setup() {
Serial.begin(9600);

pinMode(ir_car1, INPUT);
pinMode(ir_car2, INPUT);
pinMode(ir_car3, INPUT);
pinMode(ir_car4, INPUT);

pinMode(ir_enter, INPUT);
pinMode(ir_back, INPUT);

myservo.attach(3);
myservo.write(90);

lcd.int();
lcd.backlight();
lcd.setCursor(0, 1);
lcd.print(" Hi Welcome To ");
lcd.setCursor(0, 2);
lcd.print(" JustDoElectronics");
delay(5000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Today's Project ");
lcd.setCursor(0, 1);
lcd.print(" Car Parking ");
lcd.setCursor(0, 2);
lcd.print(" System ");
delay(5000);
lcd.clear();

Read_Sensor();

int total = S1 + S2 + S3 + S4;
slot = slot - total;
}

void loop() {

Read_Sensor();

lcd.setCursor(0, 0);
lcd.print(" Available Slot: ");
lcd.print(slot);
lcd.print(" ");

lcd.setCursor(0, 1);
if (S1 == 1) {
lcd.print("S1:Full ");
} else {
lcd.print("S1:Empty");
}

lcd.setCursor(11, 1);
if (S2 == 1) {
lcd.print("S2:Full ");
} else {
lcd.print("S2:Empty");
}

lcd.setCursor(0, 2);
if (S3 == 1) {
lcd.print("S3:Full ");
} else {
lcd.print("S3:Empty");
}

lcd.setCursor(11, 2);
if (S4 == 1) {
lcd.print("S4:Full ");
} else {
lcd.print("S4:Empty");
}

if (digitalRead(ir_enter) == 0 && flag1 == 0) {
if (slot > 0) {
flag1 = 1;
if (flag2 == 0) {
myservo.write(180);
slot = slot - 1;
}
} else {
lcd.setCursor(0, 0);
lcd.print(" Sorry Parking Full ");
delay(1500);
}
}

if (digitalRead(ir_back) == 0 && flag2 == 0) {
flag2 = 1;
if (flag1 == 0) {
myservo.write(180);
slot = slot + 1;
}
}

if (flag1 == 1 && flag2 == 1) {
delay(1000);
myservo.write(90);
flag1 = 0, flag2 = 0;
}

delay(1);
}

void Read_Sensor() {
S1 = 0, S2 = 0, S3 = 0, S4 = 0;

if (digitalRead(ir_car1) == 0) {
S1 = 1;
}
if (digitalRead(ir_car2) == 0) {
S2 = 1;
}
if (digitalRead(ir_car3) == 0) {
S3 = 1;
}
if (digitalRead(ir_car4) == 0) {
S4 = 1;
}
}

Welcome to the forum.

The compiler tells the line number and shows the code that causes the problem.
It has problems with: lcd.int();
Such a function does not exist and 'int' is a reserved word to declare a integer variable.
Try "lcd.init()".

Welcome to the forum

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

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.

As your topic does not relate to the operation of IDE version 1.x itself it has been moved to the Programming category of the forum

C:\Users\caith\OneDrive\Documents\Arduino\LCD\LCD.ino: In function 'void setup()':
C:\Users\caith\OneDrive\Documents\Arduino\LCD\LCD.ino:36:7: error: 'class LiquidCrystal_I2C' has no member named 'init'
lcd.init();
^~~~

exit status 1

Compilation error: 'class LiquidCrystal_I2C' has no member named 'init'

The error is almost certainly due to the fact that you are using functions for a different version of the LiquidCrystal_I2C library than you have installed

Take a look at the examples that came with the library to see the correct syntax for the library that you have

@carthandrei

Your other topic on the same subject deleted.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

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