Now, you can buy I2C LCD's, and you can even find I2C LCD's with different addresses, but they are typically two line LCD's, and the addresses are fixed. I'm going to show you how to build your own I2C interface, select one of 8 addresses, and even be able to add up to 8 inputs, using a MCP23017 16 port expander chip.
This is the same chip Adafruit uses on their I2C LCD Keypad Shield, and uses their library to talk to it. First let's look at the wiring. The connections between the Hitachi type parallel LCD (2 or 4 line) and the MCP23017 are shown below. Pins 15, 16, and 17 on the MCP23017 determine the I2C address. We have all 3 grounded, as this is the default address the Adafruit library uses. To add multiple displays, or pick another address, the library will have to be modified, so we will go with the default in the this example.
Notice the 220 Ohm resistor on the LCD k (cathode, gnd) connection. This is a MUST! Without it, you can blow the backlight pin on the MCP23017.
SDA (pin 13 on the MCP2307) connects to Arduino A4 and SCL (pin 12 on the MCP2307) connects to Arduino A5.
Download and install the Adafruit library, run the example "Hello World", and this lcd interface is operational. We will address adding inputs to this chip, and editing the library address so that up to 8 MCP23017 chips can be used in a future article. Email me with questions.
#define MCP23017_ADDRESS 0x20
Pin 17 = A2, Pin 16 = A1, and Pin 15 = A0
0 = ground, 1 = +5v
The address format is 0100A2A1A0, so since we have grounded all 3 lines, we are using binary 0100000, or 20 in hex. 0100111 would be 27 in hex.
Now figure out how to pass the address when initializing MCP23017.h ......
So, what is next? 16 channel relay boards with jumpers for address selectors? Maybe seven segment LED controllers?