Loading...
Pages: [1]   Go Down
Author Topic: problem with serial lcd from YwRobot, LCM1602 IIC  (Read 4115 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.init();
    lcd.backlight();
    lcd.setCursor(0, 0);
    lcd.print("www.b2cqshop.com");
    lcd.setCursor(0, 1);
    lcd.print("Voltage: ");
    lcd.setCursor(13, 1);
    lcd.print("V");
}
void loop()
{
    int val;
    float temp;
     val=analogRead(0);
    temp=val/4.092;
    val=(int)temp;//
    lcd.setCursor(9, 1);
    lcd.print(0x30+val/100,BYTE);
    lcd.print(0x30+(val%100)/10,BYTE);
    lcd.print('.');
    lcd.print(0x30+val%10,BYTE);
    delay(100);
}

Logged

rome
Offline Offline
Sr. Member
****
Karma: 13
Posts: 342
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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
Logged

Offline Offline
Jr. Member
**
Karma: 2
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Málaga, Spain
Offline Offline
Edison Member
*
Karma: 33
Posts: 2012
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

   

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Couldn't you just rename the new library so the two can coexist?

I haven't looked into how libraries are organised yet, but I assume it's just a set of C++ classes.  If you rename any classes that are the same in the standard library, change all the references to them to match, and rename the new library, I would have thought that would do it.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Andy,

I started with the assumption that the I2C version was a separate library, but it is not. It is a replacement for the official LCD library plus I2C.
Logged

Pages: [1]   Go Up
Print
 
Jump to: