Arduino Basics: The I2C module

The I2C Serial Interface LCD1602 module, or I2C module for the hommies, is a module that help us to reduce the number of pins we use when connecting a 16x2 display and which has its own potenciometer to adjust display contrast.

There are many ways of using an I2C module like welding it with the display pins, but today I´m showing you how to make it without welding.

We need:

  • Arduino UNO
  • Protoboard
  • I2C module
  • LCD 16x2
  • Connection wires (male-female jumpers)

This is how to connect it:

Note: You can also connect Gnd and Vcc to the protoboard.

In many diagrams the I2C module does not appear like in the previous one, and instead it looks like this:
This is because it is taken for granted that you have welded the I2C module to the display.

In any case, the next step is to include the right libraries in our program. We no longer use LiquidCrystal.h Library, and instead we use:
  • Wire.h, which is already included in Arduino Libraries.
Once you did, you must add the following lines to your code:
  • LiquidCrystal_I2C lcd(0x27,16,2); instead of LiquidCrystal lcd(2,3,4,5,6,7);
  • lcd.init(); and lcd.backlight(); instead of lcd.begin(16,2);
And that's it. Here is an example to make it clearer or if you want to check everything is ok.
//Libraries
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2); //To create the LCD object.

void setup() {
  lcd.init(); lcd.backlight(); //To initialize the interface of the screen.
  lcd.print("I love you,");
  lcd.setCursor(0,1);
  lcd.print("princess Comet.");
  delay(5000);
  lcd.clear();
}

void loop() {}

Follow me on social media as @yurrder to stay up to date with all the news about the blog and other projects.

Comments