The typical LCD used with an Arduino has 16 pins. only 6 of them have to use a I/O port on the Arduino. But what if you could get that down to two I/O pins, and still have those pins available for other devices? The I2C interface is on pins A4 and A5 of the Arduino. These have addresses, and are therefore shareable with other I2C devices that have different addresses.
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.
Become the Maker you were born to be. Try Arduino Academy for FREE!
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.
Become the Maker you were born to be. Try Arduino Academy for FREE!
Nice writeup on the 23017!