(UPDATED) Problem with IIC/I2C/TWI Serial 2004 20x4 LCD code and Arduino Uno

Hey all,

First of all, I'm new to Arduino so I'm sorry for any stupid questions (I've already messed this up once).

Now, I am working with a SainSmart IIC/I2C/TWI Serial 2004 20x4 LCD screen and an Arduino Uno, and while the screen backlight will blink, nothing actually prints. I am using the Malpartida library and have tried everything. The address for the board is definitely 0x3F (I have run a scanner), but no matter what I do it refuses to print. I found this code somewhere on this forum and modified it a bit, but I can't find anything wrong... (and yes, SDA and SCL are plugged into A4 and A5, respectively). Please help! :confused:

/*
** Example Arduino sketch for SainSmart I2C LCD2004 adapter for HD44780 LCD screens
** Readily found on eBay or http://www.sainsmart.com/ 
** The LCD2004 module appears to be identical to one marketed by YwRobot
**
** LICENSE: GNU General Public License, version 3 (GPL-3.0)
** NOTE: I2C pins are A4 SDA, A5 SCL
** Don't forget to use the new LiquidCrystal Library.
*/



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

#define I2C_ADDR    0x3F  // Define I2C Address where the SainSmart LCD is
#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

LiquidCrystal_I2C  lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin, BACKLIGHT_PIN, POSITIVE);

void setup()
{
 lcd.begin (20,4);
 
 // Switch on/off the backlight
 for(int i = 0; i< 3; i++)
  {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  lcd.backlight(); // finish with backlight on  

 // Position cursor and write some text
 lcd.home ();                   // go to the first line, first character
 lcd.print("test. ");  
 lcd.setCursor ( 0, 1 );        // go to the 2nd line
 lcd.print("todo bien. ");
 lcd.setCursor ( 0, 2 );        // go to the third line
 lcd.print("Nice LCD! ");
}

void loop()
{

}

Thank you so much!

Have you tried the I2C LCD guesser program to verify that the constructor ( LiquidCrystal_I2C lcd(...); ) has the correct values for your display?

Don

I'm not familiar with that lib, maybe this vid will help.

Hi Don,

No I haven't tried that, and for some reason that file changes to a .pde file when I download it and it refuses to open. I did use a scanner to find the address, but that's all. Is there any other way to find out if my constructor is correct?

Thanks again!

Hey Kris,

Thank you for your suggestion! I watched your video, copied and pasted the code (and modified it a bit), but the display alas still won't print anything. You have a very cool idea!

The library is FMalpartida's and is extremely useful,

https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads

if you would like to look into it.

Thank you for your help!

No I haven't tried that, and for some reason that file changes to a .pde file when I download it and it refuses to open.

It's an older sketch but according to this thread it is the latest version (v1.4.1). It opens OK for me in Aduino 1.6.7.

Don