how I can use two I2C LCD in Arduino mega

I want to know how to connect i2c LCD to mega 2560 to show different data and how I programing it?

I use UNOs but maybe this works for Megas:
This setup has been nice, especially the hd44780. It finds out the address of the I2C.

#include <SoftwareSerial.h>
#include <TinyGPS++.h>

#include <Wire.h>
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>

To start with, which LCDs? There are several kinds. 2x16 and 4x20 character LCDs based on the hd44780 driver chips and many different graphic LCDs.

The hd44780 I2C modules have an I2C expander chip on them. Some of the backpacks have a set of solder pads that you can use to set the address (see image). The base address (no pads soldered) is either 0x27 (range 0x20-0x27) or 0x3f (range 0x38-0x3f). Shorting a pad changes the base address by pulling that pin LOW.

This page explains the address setting.

Like Railroader said, the hd44780 library will make using the displays easier. Install the hd44780 library. The hd44780 library is the best available for I2C LCDs. The library is available in the Library Manager. Go to Library Manager (in the IDE menus, Sketch, Include Libraries, Manage Libraries) and in the Topics dropdown choose Display and in the Filter your search box enter hd44780. Select and install the hd44780 library by Bill Perry.

The class that you want to use is the hd44780_I2Cexp class. There are examples to show how to use the library. The nice thing about the hd44780 library is that it will autodetect the I2C address and the I2C backpack to LCD pin mapping.

I2C back pack address pads.jpg

I2C back pack address pads.jpg

I want to know how to connect i2c LCD to mega 2560 to show different data and how I programming it?

Start by connecting one I2C LCD to your Arduino (why a Mega 2560? Why not a Nano?) and practice programming it. Have you done that? If not, do it now!

Simply set each LCD at a different I2C address and treat them as individual displays which they are.

Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

I am surprised you are asking this question when if you ;
arduino 2 I2C lcd displays

There are plenty of examples showing how to do this.

Have you programmed an Arduino before?
Can you tell us your electronics, programming, arduino, hardware experience?

Thanks.. Tom.... :slight_smile: