Before you deal with getting your display to work you should modify the sketch. For your initial program you should not be trying to do anything in loop() so there should be nothing between the { and } brackets. Move the lcd.print statement to the end of setup().
You haven't specified the source of your library but you have to make sure that it was written for your particular I2C adapter and that you have the correct information in the 'constructor'.
As an alternative I suggest that you look through some of the recent threads that have I2C and/or LCD in their titles and look for a link to the hd44780 library written by Bill Perry.
Ouri1403,
The hd44780 library is available in the IDE library manager.
You can install it using the Arduino IDE GUI in just a few seconds.
It should automatically locate & detect the backpack as well as its wiring configuration settings.
You will want to use the hd44780_I2Cexp i/o class.
It also includes a diagnostic sketch (I2CexpDiag) which will test the i2c h/w and connections to the backpack.
You can read more about the library on the github page.
Do you get any errors in the IDE when you try to upload? Are you using code that came with the library or did you copy it off the net somewhere so you library and code are mismatched? Older libraries seem to use lcd.init while newer ones seem to like lcd.begin
Using "trial and error" or Guessing is a poor way to try to solve problems.
It my view, it is a waste of time.
If the address is suspect, run an i2c scanner to get the i2c address for the backpack.
If using the hd44780 library, you don't have to know the address, since it figures it out for you.
And if interested in the address, or want to test the i2c connections and the display, you can run the I2CexpDiag sketch which will report that information. It even does a memory test on the memory inside the LCD module.
Was going to suggest the i2c scan myself, but considering the OP's level, it wasn't really much of a trial and error. There are really only 2 largely likely possibilities of default address so to 'trial' would only take one try.
INTP:
Was going to suggest the i2c scan myself, but considering the OP's level, it wasn't really much of a trial and error. There are really only 2 largely likely possibilities of default address so to 'trial' would only take one try.
bperrybap:
Using "trial and error" or Guessing is a poor way to try to solve problems.
It my view, it is a waste of time.
If the address is suspect, run an i2c scanner to get the i2c address for the backpack.
If using the hd44780 library, you don't have to know the address, since it figures it out for you.
And if interested in the address, or want to test the i2c connections and the display, you can run the I2CexpDiag sketch which will report that information. It even does a memory test on the memory inside the LCD module.
--- bill
INTP:
Try changing 0x27 to 0x3F
Do you get any errors in the IDE when you try to upload? Are you using code that came with the library or did you copy it off the net somewhere so you library and code are mismatched? Older libraries seem to use lcd.init while newer ones seem to like lcd.begin
floresta:
I forgot to ask ... did you adjust the contrast potentiometer?
Don
thanks for your help freinds I checked with a scanner and i get 0x27
Again I checked this code:
What library are you using and have you installed multiple libraries trying to get this to work?
That code is VERY different from your original code.
(And I'm not referring to the code in setup() or loop() )
In this new code you are including <LCD.h>
that header is part of fm's new LiquidCrystal library; however, that library does not have a init() function as it uses begin() so it isn't clear what library you are actually using.
If you have multiple LiquidCrystal_I2C libraries installed (say fm's and some other LiquidCrystal_I2C), then you could actually be using part of one library and part of another since there would be a collision of that header file name and the IDE can't know for sure which header or library to use.
That is why multiple libraries that have the same name or use a header file with the same name is very problematic.
At this point since you appear to have the correct address, (and if it there is not some sort of h/w issue - like bad backlight or misdjusted contrast) the issue likely to be that backpack that you have does not have the PCF8574 pin wiring that the library you are using.
Unless you have an opposition to GPL v3 code,
I would highly recommend the hd44780 library as it will automatically figure out all the low level configuration stuff and has no collision issues with other libraries.
My goal with that library was to create a "it just works" library, in particular for i2c backpack based LCDs.
It can be installed in seconds using the IDE library manager.
The I2CexpDiag sketch will test the i2c connections and the LCD h/w.
That diag sketch will report a wealth of information.
It includes an I2C scanner as well as a scanner for i2c backpacks.
You literally could have the display up and running in about 1 minute if you installed the hd44780 library from the library manager. If there is an issue, then run the diag sketch and have it report the issue(s).