gmcmurry:
This all works so well, I am wondering if I can run 2 LCDs on the interface to show even more data.If I don't have to hard code the i2c address, how do I distinguish more than one LCD in my code?
Yes you can use more than a single LCD, you can use up to 16 LCDs.
While you don't have to hard code the i2c address, you can.
It isn't very obvious but here is a comment from the included MultiDisplay example sketch that explains a little more:
// It is also possible to create separate lcd objects
// and the library will still automatically find them.
// Example:
// hd4480_I2Cexp lcd1;
// hd4480_I2Cexp lcd2;
// The individual lcds would be referenced as lcd1 and lcd2
// i.e. lcd1.home() or lcd2.clear()
//
// It is also possible to specify the i2c address
// when specifying the lcd object.
// Example:
// hd44780_I2Cexp lcd1(0x20);
// hd44780_I2Cexp lcd2(0x27);
// This ensures that each each lcd object is assigned to a specific
// lcd device rather than letting the library automatically asign it.
When you have multiple LCDs you reference each one by its object name to talk to it.
i.e. lcd1.begin(16,2), lcd2.begin(16,2) etc...
The lcd object names are totally arbitrary.
i.e. you could use foo and bar as names rather than lcd1 and lcd2.
The LCDs do not have to be the same geometry.
i.e. one could be 16x2 and another might be 20x4
So there are two ways to handle multiple LCDs. You can define your two lcd objects and let the library find them and assign addresses the ones it finds or you can specify them in the constructor.
If you use multiple LCDs and do not specify addresses, there is no guarantee as to the address order they will be assigned since C++ makes not guarantees as to how constructors are called. However, form what I've seen they are called in the order they are declared.
The hd44780 library looks for backpacks from low address to high, so normally the library will assign the addresses to backpacks from lowest address to highest address in the order they are declared.
The addresses do not need to be sequential. i.e. it could be 0x20 and 0x22
When you specify an i2c address that LCD object will only talk to an LCD device at that address.
You need to choose one way or the the other and not mix lcd objects where some have specified addresses and some do not as the library currently does not fully handle this use case.
--- bill