Tuesday, April 19, 2016

I2C module with LCD display using Arduino

How to interface PCF85574 module with arduino?
To connect LCD display 16x2 or 20x4 to Arduino you know you'll need at least 6 wires to connect, it means sacrificing some IO's that could be used for connecting other components such as sensors or motors. another way is to use 74HC595 Shift register for interfacing. In this tutorial we will discuss on PCF85574 I2C LCD Display Interface.

A module that can be used to circumvent this problem is the I2C Module for LCD Display with PCF85574 (datasheet ):

I2C LCD Module for arduino
With this module, you can control an LCD display, either 16x2 or 20x4, using only two pins Arduino: the analog input pin 4 (SDA) and the analog input pin 5 (SCL) forming the I2C interface.

Module structure I2C

In the module left side we have 4 pins, and two are for power ( Vcc and GND ), and the other two are the interfaceI2C ( SDA and SCL ) . The plate pot is for display contrast adjustment, and the jumper on the opposite side allows the back light is controlled by the program or remain off for power saving.

By default the module is configured with the address 0x27 , but you can change this address using the pins A0, A1 and A2.

Step 1: Connection of I2C LCD Module with Arduino

The module has 16 pins that can be directly connected to the display, or you can test the connection in breadboard, as I did riding the circuit below where I used a 16x2 LCD display with HD44780 controller connected to the Arduino Uno: If you are using an Arduino Mega 2560, use the pin 20 (SDA) and 21 (SCL) :

Arduino I2C LCD Module Connections

Step 2: Programming I2C LCD Module with Arduino

To control this I2C module, use the library LiquidCrystal_I2C available at this link . Unzip the file and rename the folder LiquidCrystal to LiquidCrystalI2C by copying it to the folder  LIBRARIES the IDE of your Arduino.Rename the folder prevents you from having conflicts with LiquidCrystal library that is already built into the IDE.

The commands for display control are almost the same library  LiquidCrystal we use normally with commands such as lcd.begin () , lcd.print ()   and lcd.setCursor () . In I2C library, the command lcd.setBacklight () alloy (HIGH ) or off ( LOW ) the display backlight.

// Program: 16x2 LCD display and I2C module 
// blog.cirucits4you.com

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

// Initialize the display at the address 0x27 
LiquidCrystal_I2C LCD ( 0x27 , 2 , 1 , 0 , 4 , 5 , 6 , 7 , 3 , POSITIVE);
void setup ()
 lcd.begin ( 16 , 2 );
void loop ()
  lcd.setBacklight (HIGH);
  lcd.setCursor ( 0 , 0 );
  lcd.print ( "circuits4you.com" );
  lcd.setCursor ( 0 , 1 );
  lcd.print ( "LCD and I2C module" );
  delay ( 1000 );
  lcd.setBacklight (LOW);
  delay ( 1000 );

1 comment:

  1. Does this work with the latest IDE? One of the newer versions broke this library