I have a 204 LCD with an I2C adapter and I am uisng the NewLiquidCrystal library (https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home).
According to the library wiki I should be able to initialize the lcd object by specifying the I2C address only, for example LiquidCrystal_I2C lcd(0x27);
but I have found I need the full command - LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); which is the same command used for LCDs with a parallel interface.
When I specify the address only with LiquidCrystal_I2C lcd(0x27); the backlight is disabled and I get a flashing block at position 0,5.
Anybody know if I am doing something wrong or is it an issue with the library, or an issue with the screen I have?
If you use the address only in the constructor, the library will pick default pin mappings for the other parameters and they are fm's LCDXIO LCD/expander backpack device sold by fm's ElectroFun company.
No other backpack uses those pin mappings so it is guaranteed not to work with your backpack.
You also will not be able to use the backlight with that default set of pin mappings.
If you want, you could use my hd44780 library package instead.
It will auto configure everything for you, address, pin mappings, and active backlight level.
It is also faster.
You can search around the forum as I have written about it in many posts.
But the summary is install it using the IDE library manager - it does not conflict with any other library.
You can read more about it here: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
The i/o class is hd44780_I2Cexp
Run the included diagnostic sketch I2CexpDiag first, to verify that the library and LCD h/w is working correctly.
--- bill
Many thanks for this. Wanting to understand how it works but I do not have the necessary skills to dissect the library.
When using I2C, is the pin mapping the mapping from the PCF8574 chip to the LCD parallel interface?
If so, how do you find this?
I am currently playing with your library as well.
MartynC:
When using I2C, is the pin mapping the mapping from the PCF8574 chip to the LCD parallel interface?
I2C is a very broad term and not all i2c librarys handle their mapping parameters the same.
But for fm's new LiquidCrystal library LiquidCrystal_I2C i/o class, the constructor parameters represent the PCF8574 port pin numbers P0 to P7.
If so, how do you find this?
By either looking at the backpack - usually it can be determined by visual inspection if you do it prior to soldering to the LCD.
Or by using an ohm meter.
It should only take a few minutes to determine.
I am current playing with your library as well.
hd44780_I2Cexp should be able to determine the mappings automatically which is really nice as it even allows switching out backpacks without having to re-compile the sketch even if the backpacks are different and use different i2c addresses, pin mappings or backlight active levels.
It also supports manually entering them if you want.
Note that the parameter order of pins is not the same as fm's LiquidCrystal_I2C i/o class.
hd44780_I2Cexp and hd44780_pinIO use the same parameter pin ordering as the IDE LiquidCrystal library constructor pins which is different from fm's LiquidCrystal_I2C
So if manually entering the port pin numbers in the hd44780_I2Cexp i/o class constructor, pay close attention to the parameter order.
But I'd recommend using the auto configuration to let the library figure it out.
--- bill
Bill,
thank you for your detailed replies. They are most helpful.
I have had some problems with the auto-configuration in your library (regular fixed address I2C adapter) but I will experiment a little more and if I still have problems I will start a new thread.