Go Down

Topic: problem with serial lcd from YwRobot, LCM1602 IIC (Read 9 times) previous topic - next topic


hi, i have troubles trying to run the code for a serial lcd, the display have a serial module from YwRobot LCM1602 IIC, like this http://www.ebay.com/itm/New-Arduino-IIC-I2C-TWI-1602-Serial-LCD-Module-Display-/300614576737?pt=LH_DefaultDomain_0&hash=item45fe066a61,

i just find this code on the seller´s page but it won´t compile, i get an error "liquidcrystal_I2C does not name a type", but i dont know wheres the problem

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
//set the LCD address to 0x27 for a 16 chars  and 2 line display

void setup()
    lcd.setCursor(0, 0);
    lcd.setCursor(0, 1);
    lcd.print("Voltage: ");
    lcd.setCursor(13, 1);
void loop()
    int val;
    float temp;
    lcd.setCursor(9, 1);


if you bought it on ebay, often the libs are not uptodate.
Use the New LiquidCrystal lib by fm. It works. I have one lcd as your.
the sketch preamble working with me is as follows

Code: [Select]

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

The lib replace the standard one but has several advantages.
Delete the old and rename the directory LiquidCrystal_I2C.
LCD.h is inside


I am having problems with the same Ywrobot card on the back of a 20X4 display. Mine was sold by SainSmart but the provided code is marked Ywrobot. All I see is garbage characters for 2 lines.

Your problem is because the library provided by Ywrobot is for pre-1.0 Arduino. I have tried both the "official" I2C library and F Malpartida's NewLCD I2C library. I cannot display anything but garbage.


@celem - how are you initializing the library? Could you post your test code?


Ah, finally!

I have been struggling with the SainSmart on Arduino IDE version 1.0 also. I've tried several "new" LCD libraries which include I2C connections. Much of the results led to a dark, blank display with a flickering backlight. Some just remained blank. I've been through the wire library changes send/write, various init() or begin() options, and tried compiling a lot of the examples with several versions of the I2C libraries. I can compile and run the "sainlcdtest program. To do this I must first delete the LCD library that is supplied with Arduino 1.01 and then expand the rar file to replace the entire LCD library. However, when I change the program slightly, to display line 0 as a String rather than a quoted constant, the display goes back to blank with a flicker of the backlight.

Be sure to delete the original LCD library and completely replace it. If Arduino 1.01 finds the original library it will cough up a whole bunch of errors about already defined or redefined functions.

As I recall, the first error usually is that:

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

is not valid. Means that it is using the wrong LCD library. All in all I'm not happy with the attempts to replace the LCD library with one that includes I2C.

I'm still using Arduino IDE 0022 to develop my program and have an Adafruit 20x4 plus I2C backpack to test some of this stuff as well. I'll post more after getting the results organized. I've been working on this for two weeks and managed to completely confuse myself.

Go Up