Subscribe to Arduino Academy and start learning today for FREE!


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.

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.
Address hint:
Adafruit_MCP23017.h contains
#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?

Become the Maker you were born to be. Try Arduino Academy for FREE!


Notify of
1 Comment
Inline Feedbacks
View all comments
David Riewe
7 years ago

Nice writeup on the 23017!


Would love your thoughts, please comment.x