In this tutorial, I’ll show you how to connect an LCD to an I2C, which will have only 4 pins to control and use the LCD. So let’s get started.
Before using our display, we need to know its address. We can do this by using the I2C scanner code. Once we have the I2C address we can replace this value in the example code and start using it. Download sketch and upload to your Arduino. Next open Serial Monitor and copy address.
Now we can go to the appropriate program. Install library LiquidCrystal_i2c by Frank de Brabander. Set the address and size of your i2c HD44780 my is 0x3F. Set the contrast with the potentiometer. You can change the address of the i2c module by shorting after A0, A1 and/or A2.