I2C lcd

Hi, I am hoping someone can give some help here. I am trying to connect the lcd to I2C bus via an PCF8574 extender backpack using the Hello World code.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x20,16,2); // set the LCD address to 0x20 for a 16 chars and 2 line display

void setup()
{
lcd.init(); // initialize the lcd

// Print a message to the LCD.
lcd.backlight();
lcd.print(“Hello, world!”);
}

void loop()
{
}

But keep getting an error saying LiquidCrystal_I2C does not name a type, can anyone please tell me what the problem is. thanks Ernie

You should post the EXACT error message you are getting. You should also see if the error message window has scrolled some messages off the top that say (and this is very likely) that the compiler can't find the include file LiquidCrystal_I2C.h, Have you downloaded that library? Have you installed it in the right place? Have you restarted the IDE after doing that?

Hi thanks for the reply, and you are correct it tells me there is no such file as LiquidCrystal_I2C.h, but it is there in the folder.But it is there as a pde file, I assume this should be change, any clue how I should do this. Ernie

Download this Liquid I2C library: http://hmario.home.xs4all.nl/arduino/LiquidCrystal_I2C/

Unzip it and put it in your libraries folder. If you don't have a libraries folder, where your other Arduino sketches are stored, create one.

erniehatt: Hi thanks for the reply, and you are correct it tells me there is no such file as LiquidCrystal_I2C.h, but it is there in the folder.But it is there as a pde file, I assume this should be change, any clue how I should do this. Ernie

The problem is that the IDE does not actually include files from within the same folder as the PDE file if you just put them there. Instead, it uses any subdirectory of the "libraries" folder of your "sketches" folder.

[quote author=James C4S link=topic=80739.msg610133#msg610133 date=1322628844] Download this Liquid I2C library: http://hmario.home.xs4all.nl/arduino/LiquidCrystal_I2C/

Unzip it and put it in your libraries folder. If you don't have a libraries folder, where your other Arduino sketches are stored, create one. [/quote]

Thanks, I down loaded the zip file, but the results are still the same. Ernie

Thanks, I down loaded the zip file, but the results are still the same.

"Do these three things...". You did one. The results will, of course, continue to be the same.

Thanks All, I finally got there, have a good up coming festive season. Ernie

OOP"S, spoke to soon, but as soon as I tried to add it to another program, I got the same results as above I added the first three lines, tried to compile and gotthe same error, got me completely lost. Tried to upload the code but it tells be it's to large. Ernie

Tried to upload the code but it tells be it’s to large.

Darned good thing you found this issue early…

Posting the code won’t do any good if you have not installed the library in the right place.

Take some screen shots that show a directory structure where you put the library. Clearly, if the compiler can’t find the include file, you put it in the wrong place.

Now, please don’t think we are picking on you. Some library installer programs really could stand to be improved, and this might be one of them. But, we need to see where you actually put the library (and doing so might give us a hint about you operating system,which you have not mentioned).

Thanks, I have no problems with what your saying, I am grateful you take the time to answer my questions.
My operating system is Win7 home, the IDE is 0023,here are shots showing 0023 open and the inside of the libraries folder.

Snap_2011.12.02_08h13m25s_001.png

Snap_2011.12.02_08h13m59s_002.png

Aside from the fact that user installed libraries should be in the libraries folder in the user's sketch directory instead of that directory, the library should now be accessible. This presumes that the contents of that folder are correct. One more picture, please, of the contents of the LiquidCrystal_I2C folder.

Your screenshots are better than nothing, but realize you completely obscured the path. There is enough there for me to see that you didn’t listen to my original advice.

[quote author=James C4S link=topic=80739.msg610133#msg610133 date=1322628844]
Unzip it and put it in your libraries folder. If you don’t have a libraries folder, where your other Arduino sketches are stored, create one.[/quote]

Your Sketches are stored in the path:
(XP) C:\Documents and Settings\username\Arduino
(7) C:\Users\username\Documents\Arduino\

That’s where you need to create a libraries folder for you to put YOUR downloaded libraries.

See my screen shots.
User owned libraries: path where Arduino.exe stores your sketches

libraries contents and LiquidCrystal_I2C contents are the contents of the respective folders.

Contributed libraries in IDE shows how LiquidCrystal_I2C appears correct in the IDE.

Contributed Libraries in IDE.png

Ok, I now have what you suggest. The small code I entered above still compiles and runs ok. I trying to add this to code which ran fine in the original LiquidCrystal library. So far I have added the first three lines of the above code to it, and I am still getting the same errors,here are those errors. Ernie

sketch_dec02a:5: error: 'LiquidCrystal' does not name a type sketch_dec02a.cpp: In function 'void setup()': sketch_dec02a:29: error: 'lcd' was not declared in this scope sketch_dec02a.cpp: In function 'void loop()': sketch_dec02a:47: error: expected initializer before 'lcd' sketch_dec02a:48: error: 'lcd' was not declared in this scope

erniehatt: The small code I entered above still compiles and runs ok. I trying to add this to code which ran fine in the original LiquidCrystal library. So far I have added the first three lines of the above code to it, and I am still getting the same errors,here are those errors.

It is good to post the error messages you are getting. However, instead of providing a cryptic scavenger hunt, why not post the code (wrapped in code tags, provided by the '#' button in the post editor) that isn't working? Personally, I can't follow your directions and duplicate the problem. E.g, especially the vague part of "I have added..." what did you add?

As you probably realize I am new to this, and not a programmer. So I am not sure what you mean rapped in code tags. I tried copy to forum and am told file is to big, so I have zipped the file. Ernie

MultiFlash_E_3_pde.zip (2.6 KB)

So I am not sure what you mean rapped in code tags

You paste your code. Then highlight it. Click the ‘#’ button in the post editor. You’ll see what “code tags” are.


I’m really not certain I understand what this new code you posted has to do with your original I2C question. The new code you posted doesn’t make use of the I2C library and all of the digital I/O pins are consumed so you can’t use a parallel LCD. I suspect you’re making some kind of step forward (or backward) and leaving the details of that step out.

lcd.begin() should only be called once, which means it should only be in setup(), not in loop().

“Not in scope” is the complier’s way of saying it doesn’t know what a variable is. In this case, you have not defined lcd anywhere in the sketch. You should have created a global variable called lcd. Global variables go outside of setup() and loop(). It needs to be global so you can call “lcd.begin()” in setup() and then use in loop().

From the “Hello World” example of the LiquidCrystal library:

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);  // <-- this is the line that defines the object/variable "lcd"  the rest of the numbers are related to how the parallel LCD is wired.  **THIS IS HAS NOTHING TO DO WITH YOUR I2C DISPLAY.

void setup() {  // set up the LCD's number of rows and columns: 
  lcd.begin(16, 2);

Thanks

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

LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars

void setup ()
{ lcd.begin (16,2);

This is what I now have at the head of the program, and I am still getting errors.

C:\Users\Ernie\Desktop\arduino 0023\arduino-0023\hardware\tools\avr\bin\avr-ar: unable to rename ‘core.a’; reason: Permission denied

C:\Users\Ernie<mark>Desktop\arduino 0023\arduino-0023\hardware\tools\avr\bin\avr-ar
You’re one of those people, huh?

I am sorry but I don't know what that is supposed to mean