MCP23016 to lcd

Basicly I want to make a I2c controled lcd, but I can't find any good schematics or source code, would this be even possible with this i/o expander? MCP23016

any way, any help would be apriciated, and please don't go LMGTFY, I googled, a lot but it's either not code/library, or no hardware schematics, this is really hard for me to understand so, I am willing to learn but It needs to be on a newb lvl :)

would this be even possible with this i/o expander? MCP23016

Yes perfectly possible, but you might have to do a bit of work.

I use the 23016 in this project:- Down load the schematics and the schematic of how to connect it to an arduino is there, along with code functions to drive it.

Now wire it up to the LCD, I assume you are using 4 bits of data so you have a choice of what side of the expander to use along with what wires to connect to what pins. Now take the LCD library and one of the last functions in the code is the bit that actually outputs the data to the pins. Replace those few lines with calls into those functions you copied from the pendulum project, with the appropriate data values, and there you have it.

and please don't go LMGTFY, I googled, a lot

What were your search terms?. I get lots of useful information.

There's also a search box on every page of this forum, in the upper right corner.

would this be even possible with this i/o expander?

I have done it with the MCP23017 but the MCP23016 should also work.

You should also look into the offerings at


Thank you,
my Search terms were i2c arduino lcd.

but i’ll have a go at the link you gave me :slight_smile:

Grumpy I am sorry, But I get confused on what you want me to do with the code ?

I suggest that you start here which is the third hit I got using your search terms. It uses a 23008 which is essentially half of a 23016 so the required code modifications should be minimal. His LCD initialization is close to the recommended but not exactly correct -- it will probably work.


Hi got it working :) thanks for the help! helped a lot two!

and here it is in action:

Nice job - you work fast.

His (bristolwatch) LCD initialization is even worse than the one in the playground which is why I didn't recommend that link before. I just can't understand what is so hard about following the sequence that is in the datasheet.


To be honest, I just copy pasted it :) It's just a temporarily fix till something more practical (for me) comes around.

And I am studying his page, because I don't just want to copy paste, but also want to learn how and why it works :)

but also want to learn how and why it works

His code is commented more completely than most so that will help.

Try going through the code and figuring out where all the 'magic numbers' come from.

For example this part deals with the LCD controller. You will have to use your Google skills to come up with a data sheet for the HD44780 controller. Then you will have to look through that data sheet to find the 'Instructions' that the controller uses. Finally you have to compare the magic numbers with the instructions. Unless you are fluent in Hex you should convert the magic numbers to binary. If you try converting everything to decimal you are doomed.

const byte HOME = 0x02;
const byte CL = 0x10; // cursor left
const byte CR = 0x14; // cursor right
const byte SL = 0x18; // Shifts entire display left
const byte SR = 0x1c; // Shifts entire display right


Edit: Homework - (1) explain why this is so: The address of the MCP23016 is 0x20. (2) explain how to change it. (3) explain why you might want to do so.

Want to share this with you all, you might find it interesting :)

Greets, Duality