LCM1602 I2C not working

Hi everyone,

I’ve got LCM1602 module attached to the LCD that i’ve purchased recently. But have trouble getting it to work.After some google search i found this link ===> http://forum.arduino.cc/index.php?topic=158312.0

and download the sample code and the libraries. STILL DOSE NOT work!!

I have GND, VCC, SDA, SCL out from the module and all the pins from the LCD are soldered to the module.

But in the program that i have found they defined the LCD pins and use it in liquidCristal library.

Could anyone possibly help out here???

Thanks

P.S. the code i found:

/* YourDuino.com Example Software Sketch
20 character 4 line I2C Display
ANOTHER NEW TYPE Marked "LCM1602 IIC  A0 A1 A2"
A0-A1-A2 are grounded so I2C Address is 0x20  
terry@yourduino.com */
/*-----( Import needed libraries )-----*/ 
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library
//Download: https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move original LiquidCrystal library elsewhere, copy this in it's place

/*-----( Declare Constants )-----*/
#define I2C_ADDR    0x20  // Define I2C Address for the PCF8574T 
//---(Following are the PCF8574 pin assignments to LCD connections )----
// This are different than earlier/different I2C LCD displays
#define BACKLIGHT_PIN  3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

#define  LED_OFF  1
#define  LED_ON  0

/*-----( Declare objects )-----*/  
LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
 lcd.begin (16,2);  // initialize the lcd 
// Switch on the backlight
 lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
 lcd.setBacklight(LED_ON);
}// END Setup

void loop()   /*----( LOOP: RUNS OVER AND OVER AGAIN )----*/
{

// Reset the display  
 lcd.clear();
 delay(1000);
 lcd.home();
 
// Print our characters on the LCD
 lcd.backlight();  //Backlight ON if under program control
 lcd.setCursor(3,0); //Start at character 3 on line 0
 lcd.print("Hello, world!");
 delay(1000);
 lcd.setCursor(2,1);
 lcd.print("From YourDuino");
 delay(1000);  
 lcd.setCursor(0,2);
 lcd.print("20 by 4 Line Display");
 //lcd.setCursor(0,3);
 //delay(2000);   
 //lcd.print("http://YourDuino.com");
 //delay(8000);
} // END Loop

The address of your LCD may be different.

Try scanning the address using this.

http://playground.arduino.cc/Main/I2cScanner

thanks mate,

now i have an error saying:

In file included from sketch_dec17c.ino:9:0:
C:\Program Files (x86)\Arduino\libraries\LiquidCrystal_I2C/LiquidCrystal_I2C.h:34:19: fatal error: I2CIO.h: No such file or directory
#include "I2CIO.h"

:confused:

Sounds like you need this version of the LiquidCrystal_I2C Library.

No, you need the fmalpartida library installed, you need the liquidcrystal library provided with the IDE completely removed, and you need to run the "guesser" sketch to determine the correct descriptor which you then use in your own code.

Which is all detailed in that other thread.

If that does not work, then (and I presume this is in fact the case,) you have not connected SDA and SCL correctly or not adjusted the "contrast" potentiometer. But you didn't mention that, did you?

You (the OP) appear to be running one of the examples from the 'yourduino' site.

I have found those tutorials to be quite good if you select the correct one and follow it properly. So - which one did you use and why did you pick that one?

Incidentally the author of that tutorial, 'terryking228', used to be a frequent contributor to this forum but he seems to be concentrating on other sections lately, possibly to avoid any conflict of interest.

Don

Hi @Paul__B & @ floresta, I already have downloaded the fmalpartida library, but didn't delete the liquidcristal that came with the IDE.
so that solves the compiling issue! Thanks. I'm using Mega 2560 so i'm connecting the SDA and SCL directly to the pins marked on the board.

on the down part I'm still not getting anything on the LCD, it just flashes on and off in respect to the delays in the program @ "guesser" sketch.

I purchased this LCD off eBay and it came with this I2C adaptor attached to it. I was looking for example codes and ways to get it running that i came across that tutorial. Sure it is useful!!

But still my confusion is that i don't have anything connected to the digital pins :

#define BACKLIGHT_PIN 7
#define En_pin 4
#define Rw_pin 5
#define Rs_pin 6
#define D4_pin 0
#define D5_pin 1
#define D6_pin 2
#define D7_pin 3

#define LED_OFF 0
#define LED_ON 1

just the SDA, SCL, GND and VCC are connected....

What about the "contrast" potentiometer?

But still my confusion is that i don't have anything connected to the digital pins . . .

Typically an LCD is used to provide information about something that your Arduino is controlling. The devices that are being controlled require the use of microprocessor I/O pins.

You are using an I2C adapter to free up some microprocessor pins for other uses. It uses only two pins to run the LCD rather than the six that would otherwise be required. Those two pins, SDA and SCL, can still be used to control other I2C devices so in such cases no pins are 'lost' to the LCD.

The pin numbers that you supply to the fmalpartida library refer to the pins on the integrated circuit that is on your I2C adapter, not to the Arduino pins. There are no standards for those connections, each adapter manufacturer is free to choose their own pc board layout and in that process choose which IC pins drive which LCD pins.

Don

Paul__B:
What about the "contrast" potentiometer?

the contrast pot works well. I mean it does it's job!!

floresta:
The pin numbers that you supply to the fmalpartida library refer to the pins on the integrated circuit that is on your I2C adapter, not to the Arduino pins. There are no standards for those connections, each adapter manufacturer is free to choose their own pc board layout and in that process choose which IC pins drive which LCD pins.

Sadly I found that out last night with the help of other friends here.
The manufacturer has not gone through the trouble of marking the pins :confused: so I guess i"ll attack the adaptor with a multimeter to find out what pin is connected to what leg of the chip. and try finding some documentation on the chip that they have used.

I’ve attached the documentation for PCF8574 Chip that is on my adaptor.

and here is how it’s connected to the LCD pins:

Vss = Vcc
Vdd = GND
these two are connected straight to the headers that will connect to arduino

V0 = -
RS = Pin 4
RW= Pin 5
E = Pin 6
D0 = -
D1 = -
D2 = -
D3 = -
D4 = Pin 9
D5 = Pin 10
D6 = Pin 11
D7 = Pin 12
A = Pin 16
K = -

and the address of the LCD is 0x27

and here is the updated example code that i’m using:

/* YourDuino.com Example Software Sketch
16 character 2 line I2C Display
NEW TYPE Marked "Arduino-IIC-LCD GY-LCD-V1"
terry@yourduino.com */
/*-----( Import needed libraries )-----*/ 
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library

/*-----( Declare Constants )-----*/
#define I2C_ADDR    0x27  // Define I2C Address for the PCF8574A 
//---(Following are the PCF8574 pin assignments to LCD connections )----
// This are different than earlier/different I2C LCD displays
#define BACKLIGHT_PIN  3
#define En_pin  6
#define Rw_pin  5
#define Rs_pin  4
#define D4_pin  9
#define D5_pin  10
#define D6_pin  11
#define D7_pin  12

#define  LED_OFF  0
#define  LED_ON  1

/*-----( Declare objects )-----*/  
LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
 lcd.begin (16,2);  // initialize the lcd 
// Switch on the backlight
 lcd.setBacklightPin(BACKLIGHT_PIN,NEGATIVE);
 lcd.setBacklight(LED_ON);
}// END Setup

void loop()   /*----( LOOP: RUNS OVER AND OVER AGAIN )----*/
{

// Reset the display  
 lcd.clear();
 delay(1000);
 lcd.home();
 
// Print our characters on the LCD
 lcd.backlight();  //Backlight ON if under program control
 lcd.setCursor(0,0); //Start at character 0 on line 0
 lcd.print("Hello, world!");
 delay(1000);
 lcd.setCursor(0,1); //Start at character 0 on line 1
 lcd.print("16 by 2 Display");
 delay(8000);
} // END Loop

PCF8574.pdf (133 KB)

on the down part I'm still not getting anything on the LCD, it just flashes on and off in respect to the delays in the program @ "guesser" sketch.

I do not believe that there has been a documented case of the guesser failing. Please read the instructions carefully. There appear to be only a limited set of constructors, and they are shown in the guesser code.

If indeed, you have an adaptor with a supported chipset, and the guesser sketch does not work, and you find a new constructor, please be sure to report back here.

This is not a known constructor. Does it work? If not, I'm not sure you have the chip oriented correctly when you count pins around the edge.

#define BACKLIGHT_PIN  3
#define En_pin  6
#define Rw_pin  5
#define Rs_pin  4
#define D4_pin  9
#define D5_pin  10
#define D6_pin  11
#define D7_pin  12

I downloaded the guesser again and it gave me

0x27,2,1,0,4,5,6,7,3,POSITIVE

I modified the sample code that i was using and it Works

/* YourDuino.com Example Software Sketch
16 character 2 line I2C Display
NEW TYPE Marked "Arduino-IIC-LCD GY-LCD-V1"
terry@yourduino.com */
/*-----( Import needed libraries )-----*/ 
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>  // F Malpartida's NewLiquidCrystal library

/*-----( Declare Constants )-----*/
#define I2C_ADDR    0x27  // Define I2C Address for the PCF8574A 
//---(Following are the PCF8574 pin assignments to LCD connections )----
// This are different than earlier/different I2C LCD displays
#define BACKLIGHT_PIN  3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

#define  LED_OFF  0
#define  LED_ON  1

/*-----( Declare objects )-----*/  
LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

void setup()   /*----( SETUP: RUNS ONCE )----*/
{
 lcd.begin (16,2);  // initialize the lcd 
// Switch on the backlight
 lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
 lcd.setBacklight(LED_ON);
}// END Setup

void loop()   /*----( LOOP: RUNS OVER AND OVER AGAIN )----*/
{

// Reset the display  
 lcd.clear();
 delay(1000);
 lcd.home();
 
// Print our characters on the LCD
 lcd.backlight();  //Backlight ON if under program control
 lcd.setCursor(0,0); //Start at character 0 on line 0
 lcd.print("Hello, world!");
 delay(1000);
 lcd.setCursor(0,1); //Start at character 0 on line 1
 lcd.print("16 by 2 Display");
 delay(8000);
} // END Loop

What I was doing earlier was checking the direct connections from the LCD pins to the chip pins

Oops! I stand corrected. I see that it does have the serial
interface in it.
You are using LiquidCrystal_I2C.h and not LiquidCrystal.h. That should
work fine.
I suspect there is a LiquidCrystal_SPI.h as well someplace.
Dwight