Go Down

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

Proyex

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);
}


brunialti

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

celem

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.

fm

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

jgrina

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.

Andy2No

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.

jgrina

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.

floresta

#7
Nov 19, 2013, 11:45 pm Last Edit: Nov 20, 2013, 04:25 am by floresta Reason: 1
EDIT: NO I AM NOT AN IDIOT.  The reply to which this message relates was posted on November 19, 2013 and then removed after I posted this.  I usually include a quote to avoid situations like this but I forgot to do that this time.

You have resurrected another old thread.

I have the same advice for you today as I did yesterday: -->
http://forum.arduino.cc/index.php?topic=138674.msg1473520#msg1473520

You should use the old threads for reference, but start a new one for your problem.

Don

raschemmel

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

raschemmel

Don,
I know you said this is an old thread but I got my YwRobot I2C LCD working.with some help from Liu Shuan at
DFROBOT.  Do you want me to do anything with the information or just drop the subject ?
Your call. I am trying to offer a solution to the above posts on the "old thread'.
Based on the above posts isn't this relevant ?
You 'suggested' I open a new thread. What should I call it ? (YwRobot: "No Problem found ?"
If you say no I'll remove this post.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

floresta

Quote
Ok, sorry.
Won't happen again, I hope...

Here's something else you should not do again ... remove a post that will disrupt the flow of a thread, as you did earlier today.

Don

floresta

Quote
Do you want me to do anything with the information or just drop the subject ?

Maybe I misinterpreted what was in your (now deleted) post.  It appeared to me at the time that you did not have a solution, you were just adding your problem on to the old one.  

Now that you do have a solution I certainly don't think you should drop the subject since the information you got from DFROBOT will be of interest to others with the same problem.  

Since this stuff is now a part of that old thread, and it is therefore no longer an old thread, it might be appropriate to put your solution here.  

Another option would be to start a new thread with a link to that thread here.  You could use a title of "SOLUTION to problem with serial lcd from YwRobot, LCM1602 IIC" or "Problem with serial lcd from YwRobot, LCM1602 IIC [SOLVED]".

In your post you should outline the symptoms and then give the solution that you found.  


Don

raschemmel

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Go Up