SainSmart LCD1602 Module Display [how do i use this?]

Hi all!
arduinofreaklol here!

I have a SainSmart LCD1602 Module Display and I was wondering how it works.
Here is a pic:

Hopefully that came up :\

It has 4 pins:
GND, VCC, SDA, and SCL.

How do i use this?

Example code (for this module specifically) would be nice!

:slight_smile:

arduinofreaklol

arduinofreaklol:
Here is a pic:

Hopefully that came up

No it didn't - as you knew when you used "Preview" - because it was not a picture URL. Or indeed, a URL at all.

Have you tried using the "Example Arduino Sketch" on the Sainsmart web page?

Another choice is here: --> http://arduino-info.wikispaces.com/LCD-Blue-I2CDon

EDIT: Fixed link: http://arduino-info.wikispaces.com/LCD-Blue-I2C

Don

here are a couple of youtube videos with downloadable source code that includes the pin connections.

Hi again!

After searching Google for the 100th time, I found some code for the lcd! :slight_smile:

(The lcd is actually a sainsmart IIC/I2C/TWI 1602 Serial LCD Module Display (that’s what I searched))

There’s only one problem:
There’s an ERROR!!! >;O

Here’s the code:

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

LiquidCrystal_I2C lcd(0x3f, 16, 2);

void setup() {
  lcd.init();
  lcd.backlight();
}

void loop() {
  lcd.print("Hello There!");
  lcd.setCursor(0, 1);
  lcd.print("Im an Arduino");
  delay(100);
}

This is the error:

sainsmart_lcd_test_2.ino: In function 'void setup()':
sainsmart_lcd_test_2:8: error: 'class LiquidCrystal_I2C' has no member named 'init'
'class LiquidCrystal_I2C' has no member named 'init'

I don’t know what’s going on! >:(
I have exactly what’s in the program (I got this off a website) and the right library but it just doesn’t work!

:frowning:

How do I fix this?

arduinofreaklol

How do I fix this?

I for one am not inclined to come up with any more possible solutions until you comment on your success or lack thereof with the ones I proposed earlier.

Don

floresta, I tried, but it wouldn't let me see the code unless I signed in by creating an account but I don't have permission to do that (I'm only 13), so...yeah......

Oh! And I'm not allowed to go on youtube, so ... sorry KrisKasprzak.....

:expressionless:

It looks like I messed up the link. Some how my name 'Don' got appended to the actual link and that somehow causes the sign-in message to appear. I don't know why it worked for me when I checked the link before posting.

Try this version: http://arduino-info.wikispaces.com/LCD-Blue-I2C

Don

Oh, no!

Sorry, floresta, I forgot to mention that my lcd is 16 by 2, not 20 by 4....and the instructions on that link are for 20 by 4. Do you have one for 16 by 2?

thx

arduinofreaklol

The interface is exactly the same regardless of the display configuration.

This is because the controller is exactly the same and there is no way to inform the controller what size display it is controlling.

If you try to write information to the lower two rows or to the positions past the 16 available on each row of your device they simply will not be displayed.

Don

Hi again…

… waffle…

OK! I found the code for the lcd (The code from the link that floresta gave me) and it worked…ish…
…There was an error…

…waffle…

Here’s the code:

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

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2);
  
  for(int i = 0; i < 3; i++) {
    lcd.backlight();
    delay(250);
    lcd.noBacklight();
    delay(250);
  }
  
  lcd.backlight();
  
  lcd.setCursor(0, 0);
  lcd.print("Hello, buddy!");
  delay(1000);
  lcd.setCursor(0, 1);
  lcd.print("Life is good!");
  delay(8000);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Use the Serial Mon");
  lcd.setCursor(0, 1);
  lcd.print("to display type");
}

void loop() {
  {
    if(Serial.available()) {
      delay(100);
      lcd.clear();
      while(Serial.available() > 0) {
        lcd.write(Serial.read());
      }
    }
  }
}

Here’s the error:

sainsmart_lcd_test_3:4: error: 'POSITIVE' was not declared in this scope
sainsmart_lcd_test_3.ino: In function 'void setup()':
sainsmart_lcd_test_3:8: error: no matching function for call to 'LiquidCrystal_I2C::begin(int, int)'
sainsmart_lcd_test_3.ino:8:18: note: candidate is:
In file included from sainsmart_lcd_test_3.ino:2:0:
C:\Users\kaiser academy\Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note: void LiquidCrystal_I2C::begin()
  void begin();
       ^
C:\Users\kaiser academy\Documents\Arduino\libraries\Arduino-LiquidCrystal-I2C-library-master/LiquidCrystal_I2C.h:76:7: note:   candidate expects 0 arguments, 2 provided
'POSITIVE' was not declared in this scope

…waffle…

How do I fix this so that it works?
I’ve almost had it with this lcd!..

…waffle…

arduinofreaklol

#include <LiquidCrystal_I2C.h>

This doesn’t tell us much without knowing the source of the library that you are using since they all seem to have the same name.

If you are following the corrected link that I provided then you should be using the ‘New LiquidCrystal Library’. In that case you probably have not carefully followed all of the instructions for installing the library.

If you are using another tutorial then it may use a different library. Since the libraries have the same names it is important to get the correct components installed where they belong and get rid of all traces of any other similarly named library.

Don

floresta:
... there is no way to inform the controller what size display it is controlling.

In hardware, that is. So you have to use the correct software instructions which the library determines when you specify the size in your initial call.

floresta:
If you try to write information to the lower two rows or to the positions past the 16 available on each row of your device they simply will not be displayed.

But may be scrolled to as I understand it.

There is no way to tell the controller what size display it is controlling ... PERIOD. This is the reason why the interface is the same regardless of the configuration of the display.

I'm trying to keep things simple and respond to the questions at hand without being incorrect and without introducing any extra information which at this point may be confusing.

You can give the display configuration information to the software and it in turn can figure out which memory locations to use for the characters but that is as far as it goes.

Once he gets his display working he can indeed use shifting (which in Arduinoese is called scrolling) to view otherwise un-displayed characters. The characteristics of the shifting mechanism frequently make this a less than fulfilling experience.

Don

floresta:
The characteristics of the shifting mechanism frequently make this a less than fulfilling experience.

And in fact, that (clever understatement) is the point - these limited displays are really only useful for static data - not to say the data may not be changing, but moving around in such a small space just does not make much sense.

Is there any other source I can use?
(any other websites?)

Is there any other source I can use?

We cannot point you to another source unless we know what source you are presently using, a question that I asked back in reply #11.

Don

floresta.

I didn't get the library from the link you gave me....
I got it from some other website that I cannot remeber.

Sorry :frowning:

I didn't get the library from the link you gave me....
I got it from some other website that I cannot remeber.

You can't use just any old library with any I2C adapter even though the libraries have the same name.

I don't understand why you want me to recommend yet another source when you haven't tried the two that I recommended a week ago.

You can use the one that is supplied by the distributor of your adapter which was my first recommendation or you can use a 'universal' library that is known to work reliably with many adapters which is described in my second recommendation.

Don

We use the 20x4 but we modified the code of the 16x2.

You will need to install the LiquidCrystal_I2C.

This is the sketch we use to test our LCDs. You can use it to give you an idea how to work with it.

/*
 This sketch will display a series of numbers 0-44 on a LCD screen 20x4 filling each line with consecutive numbers until it reaches
 the end and then it starts again. 
 
 Code used for learning purposes developed by: www.HackerspaceLA.org | @hackerspacela 
 Code modified from Adafruit at: https://www.arduino.cc/en/Tutorial/LiquidCrystalAutoscroll
 This example code is in the public domain: http://www.arduino.cc/en/Tutorial/LiquidCrystalAutoscroll
 */
 // include the library code:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

//#define pins:

#define I2C_ADDR    0x27 // LCD address (make sure you run the I2C scanner to verify our LCD address)
#define Rs_pin  0        // Assign pins between I2C and LCD
#define Rw_pin  1
#define En_pin  2
#define BACKLIGHT_PIN 3
#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);


// initialize the library with the numbers of the interface pins

void setup() {
  // set up backlight and turn on module:
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
  // set up the LCD's number of columns and rows:
lcd.begin(20, 4); //My LCD is 20x4
}

void loop() {
  // set the cursor to (0, 0) on line #1
  lcd.setCursor (0, 0);
  //lcd.autoscroll();
  // print from 0 to 14:
  for (int thisChar = 0; thisChar < 15; thisChar++) {
    lcd.print(thisChar);
    lcd.leftToRight();
    delay(500);
  }

  // set the cursor to (0, 1) on line #2
  lcd.setCursor (0, 1);
  // set the display to automatically scroll:
  //lcd.autoscroll();
  // print from 0 to 14:
  for (int thisChar = 15; thisChar < 25; thisChar++) {
    lcd.print(thisChar);
    delay(500);
  }

    // set the cursor to (0, 1) on line #3
  lcd.setCursor (0, 2);
  // set the display to automatically scroll:
  //lcd.autoscroll();
  // print from 0 to 14:
  for (int thisChar = 25; thisChar < 35; thisChar++) {
    lcd.print(thisChar);
    delay(500);
  }

    // set the cursor to (0, 1) on line #4
  lcd.setCursor (0, 3);
  // set the display to automatically scroll:
  //lcd.autoscroll();
  // print from 0 to 14:
  for (int thisChar = 35; thisChar < 45; thisChar++) {
    lcd.print(thisChar);
    delay(500);
  }
    
  // turn off automatic scrolling
  lcd.noAutoscroll();

  // clear screen for the next loop:
  lcd.clear();
}

See example in action here: https://goo.gl/photos/yqhsG5i93vbi22qa7