Go Down

Topic: SainSmart 20 x 4 LCD wanting to use I2C from Arduino Uno (Read 18 times) previous topic - next topic


Andrew!!!!!!  You are the Man!   I just hooked it up , downloaded library and uploaded and it worked like a champ!   Thank you so much bro!


Andrew!!!!!!  You are the Man!   I just hooked it up , downloaded library and uploaded and it worked like a champ!   Thank you so much bro!

Hey that's great!!! I'm really glad you got it working! I'm loving playing with this LCD too.




You did use my New LiquidCrystal library right?

The whole thing is that these folks sell their stuff and rely on someone else to sort it out for them. The link in the LCD product page is not for my library (didn't check). But if it was, they could at least mention how they've mapped the I2c extender pins to the LCD to simplify the initialisation and use of what they sell!


It is a zipped image of my library the one they have on their site! http://www.sainsmart.com/home-page-view/sainsmart-iic-i2c-twi-serial-2004-20x4-lcd-module-shield-for-arduino-uno-mega-r3.html

They have even writen a sample sketch to go with it that is not correctly initialised as it uses 0x27 as its base address as opposed to 0x3F used by you LCD module. The sample sketch is called "sainlcdtest".

Code: [Select]
** 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
** Address pins 0,1 & 2 are all permenantly tied high so the address is fixed at 0x27
** Written for and tested with Arduino 1.0
** This example uses F Malpartida's NewLiquidCrystal library. Obtain from:
** https://bitbucket.org/fmalpartida/new-liquidcrystal
** Edward Comer
** LICENSE: GNU General Public License, version 3 (GPL-3.0)
** NOTE: TEsted on Arduino NANO whose I2C pins are A4==SDA, A5==SCL
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#define I2C_ADDR    0x27  // Define I2C Address where the PCF8574A 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

int n = 1;

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

void setup()
  lcd.begin (20,4);
// Switch on the backlight
  lcd.home ();                   // go home

  lcd.print("SainSmart I2C tester"); 
  lcd.setCursor ( 0, 1 );        // go to the 2nd line
  lcd.print("F Malpartida library");
  lcd.setCursor ( 0, 2 );        // go to the third line
  lcd.print("Test By Edward Comer");
  lcd.setCursor ( 0, 3 );        // go to the fourth line
  lcd.print("Iteration No: ");

void loop()
  // Backlight on/off every 3 seconds
  lcd.setCursor (14,3);        // go col 14 of line 3
  lcd.setBacklight(LOW);      // Backlight off
  lcd.setBacklight(HIGH);     // Backlight on

How intersting!



Yes...your Library you were trying to Direct me to was the same Andrew was......and the one sainsmart has you download is the same as well.

Here is what i was doign wrong all along!   So In the beginning I had my I2C scanner running so I knew it was address 0x3F i was communicating with right?

Well when I had first downloaded that new LiquidCrystal Library...I discarded the other liquidCrystal library that is in 1.0.1 but what I was doing wrong:  I didn't discard the LiquidCrystal_I2C library I had downloaded before...it kept wanting to use that one......because the LiquidCrystal_i2c.h  and LCD.h  is already in the new LiquidCrystal library.....Now I just have to tinker with the code to make it say what I want in the loop etc...

But you guys have been so great and patient...I REALLY APPRECIATE it.....

Thanks to FM and Andrew......

Go Up