PROBLEM WITH CODE FOR LCD SERIAL

//load libraries
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
//Define variables
#define I2C_ADDR 0x27 //Define I2C Address where the PCF8574A is
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
//Initialise the LCD
LiquidCrystal_I2C lcd(I2C_ADDR, En_pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);
LCD.begin (20,4);
LCD.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
LCD.setBacklight(HIGH);
LCD.setCursor(0,0);
LCD.print("CAVALLO");
LCD.setCursor(0,1);
LCD.print("MARMOTTA");

I have a problem with this programbeacuse at the moment to verify it pc shows me this error :

_20x4:17: error: expected unqualified-id before '.' token

 LCD.begin (20,4);

    ^

_20x4:18: error: expected unqualified-id before '.' token

 LCD.setBacklightPin(BACKLIGHT_PIN, POSITIVE);

    ^

_20x4:19: error: expected unqualified-id before '.' token

 LCD.setBacklight(HIGH);

    ^

_20x4:20: error: expected unqualified-id before '.' token

 LCD.setCursor(0,0);

    ^

_20x4:21: error: expected unqualified-id before '.' token

 LCD.print("CAVALLO");

    ^

_20x4:22: error: expected unqualified-id before '.' token

 LCD.setCursor(0,1);

    ^

_20x4:23: error: expected unqualified-id before '.' token

 LCD.print("MARMOTTA");

    ^

exit status 1
expected unqualified-id before '.' token

what is wrong ?

The type of library that you are using is for I2C. While I2C is a serial type of bus, when the term "Serial" is used, it generally refers to asynchronous serial and not i2c.

The specific errors you have shown are because you named the object "lcd" but then attempted to use the object with the name "LCD".

But the code that you posted is not a valid Arduino sketch and will not work even if you correct that issue.

You should read up on Arduino sketches and how they are structured, look at some working examples to see how the setup() and loop() functions are declared and the code within them is filled in.

If you want, you could take at my hd44780 library.
It will automatically locate the i2c address for the backpack and self configure all the pin mappings.

It is available in the Arduino IDE library manager.
You can read more about it here: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library

The hd44780 library has multiple i/o classes for different types of LCDs.
The i/o class that you will want for an LCD that is using an I2C backpack is hd44780_I2Cexp
The library includes ready to run example sketches down under ioClass/h444780_I2Cexp examples.

There is a sketch called I2CexpDiag that will run a diagnostic check on your i2c signals and test the LCD module RAM. See the sketch for instructions on how to run it.

--- bill