I2C Arduino Code for LCD Displays & Adaptor Modules

Click Here to watch our YouTube Video for a full description
To use an I2C ready LCD Display or I2C Backpack Adaptor Module with Arduino you will need the Wire Library and a Library for I2C LCD.

In our video, we used the NewLiquidCrystal Library.  Wire is already included in the Arduino IDE but you will need to download NewLiquidCrystal - click here to download:
NewLiquidCrystal

UPDATE:

Since that video was made, we have switched to using the hd44780 Library:

Created by Bill Perry 2016-07-02
bperrybap@opensource.billsworld.billandterrie.com
This example code is unlicensed and is released into the public domain

Read more about this library here:
https://www.arduino.cc/reference/en/libraries/hd44780/ 
and the documentation on gitHub is here:
https://github.com/duinoWitchery/hd44780

In the library manager, search for hd44780 and then download it - it will soon be ready to use and will appear in your libraries menu.
The example sketches will then also be available in the Open file dialogue.

Here's a short Arduino Sketch you can copy and paste to show the basic set up of an LCD Display using the hd44780 library:

/*

WWW.Q26.CO.UK

I2C hd44780 Library Demo Code

********************************************************************************

Acknowledgements:

Created by Bill Perry 2016-07-02

bperrybap@opensource.billsworld.billandterrie.com


This example code is unlicensed and is released into the public domain

----------------------------------------------------------------------------

*/


//Libraries

#include <Wire.h>

#include <hd44780.h> //replaces LiquidCrystal

#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header


//LCD Display initialise:

hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip

const int LCD_COLS = 16;

const int LCD_ROWS = 2;


void setup() {

  lcd.begin(LCD_COLS, LCD_ROWS);  

  lcd.clear();

  lcd.setBacklight(HIGH);


  //Initial Display

  lcd.setCursor(0, 0);

  lcd.print("Hello World");

  delay(3000); 

}


void loop() {

  lcd.clear();

  lcd.setCursor(0, 0);

  lcd.print("hd44780 Library");

  lcd.setCursor(0, 1);

  lcd.print("...working here");

  delay(3000);

  lcd.clear();

  lcd.setCursor(0, 0);

  lcd.print("COls & ROWS");

  lcd.setCursor(0, 1);

  lcd.print("16 & 2");

  delay(3000);

}