Picture of I2C LCD Controller (the easy way)
I am working on an alarm/weather station project and I wanted to use an LCD but dint want to have a lot of wires so I order a controller. This is just a very basic tutorial on how to hook it up, for the beginners like my self.

Step 1: Parts

Picture of Parts

Parts list:




1. LCD in this case a 16x02


1. I2C 1602 LCD Controller ($1.99 on ebay free shipping)


4. Jumper wires


1. Arduino ( I have a mega)    


ArcAiN62 days ago

Is it possible to connect one of these I2C backpacks to an LCD Keypad shield?

I ask because i have one of these:


And i also have a PCF8574T I2C module.

If i add this module, how would i maintain usage of the keys on the keypad? Is it as simple as running the A0 pin from the keypadshield to the A0 of the arduino?

ashishr2114 days ago

hey i have 20*04 lcd. Is that lcd work with i2c controller?

verdelj (author)  ashishr2111 days ago
You need to buy a controller for your particular lcd in your case one that will run a 20x04 lcd. You can buy them online really cheap. And you can modify the code to work
turbiny22 days ago

just posting maybe someone will need this
i ordered from aliexpress and this is the code the worked after a week of trying:
i did altered some comments

/* YourDuino.com Example Software Sketch

20 character 4 line I2C Display

Backpack Interface labelled "LCM1602 IIC A0 A1 A2"

terry@yourduino.com */

/*-----( Import needed libraries )-----*/

#include <Wire.h> // Comes with Arduino IDE

// Get the LCD I2C Library here:

// https://bitbucket.org/fmalpartida/new-liquidcryst...

// Move any other LCD libraries to another folder or delete them

// See Library "Docs" folder for possible commands etc.

#include <LiquidCrystal_I2C.h>

/*-----( Declare Constants )-----*/


/*-----( Declare objects )-----*/

// set the LCD address to LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); for a 16 chars 2 line display

// Set the pins on the I2C chip used for LCD connections:

// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

/*-----( Declare Variables )-----*/


void setup() /*----( SETUP: RUNS ONCE )----*/


Serial.begin(9600); // Used to type in characters

lcd.begin(16,2); // initialize the lcd for 16 chars 2 lines and turn on backlight

// ------- Quick 3 blinks of backlight -------------

for(int i = 0; i< 3; i++)







lcd.backlight(); // finish with backlight on

//-------- Write characters on the display ----------------

// NOTE: Cursor Position: CHAR, LINE) start at 0

lcd.setCursor(2,0); //Start at character 4 on line 0

lcd.print("hello BEBUSH!");



lcd.print("WE <3 YOU");



lcd.print("16by2 Line Display");





// Wait and then tell user they can start the Serial Monitor and type in characters to

// Display. (Set Serial Monitor option to "No Line Ending")

lcd.setCursor(0,0); //Start at character 0 on line 0

lcd.print("Start Serial Monitor");


lcd.print("Type chars 2 display");

}/*--(end setup )---*/

void loop() /*----( LOOP: RUNS CONSTANTLY )----*/



// when characters arrive over the serial port...

if (Serial.available()) {

// wait a bit for the entire message to arrive


// clear the screen


// read all the available characters

while (Serial.available() > 0) {

// display each character to the LCD





}/* --(end main loop )-- */

/* ( THE END ) */

jdayer1 month ago
I ordered a couple of lcd displays and a serial controller off of eBay. I've been reading some tutorials and i like yours. Great job!
malthemail4 months ago

i get this error:

Arduino: 1.6.3 (Windows 8.1), Board: "Arduino Uno"

C:\Users\malthemail\Documents\Arduino\libraries\fmalpartida-new-liquidcrystal-67c63469f5ed\I2CIO.cpp:54:3: error: 'Wire' does not name a type



C:\Users\malthemail\Documents\Arduino\libraries\fmalpartida-new-liquidcrystal-67c63469f5ed\I2CIO.cpp:55:3: error: 'error' does not name a type

error = Wire.endTransmission();


C:\Users\malthemail\Documents\Arduino\libraries\fmalpartida-new-liquidcrystal-67c63469f5ed\I2CIO.cpp:56:3: error: expected unqualified-id before 'if'

if (error==0){


C:\Users\malthemail\Documents\Arduino\libraries\fmalpartida-new-liquidcrystal-67c63469f5ed\I2CIO.cpp:59:3: error: expected unqualified-id before 'else'

else //Some error occured


C:\Users\malthemail\Documents\Arduino\libraries\fmalpartida-new-liquidcrystal-67c63469f5ed\I2CIO.cpp:63:1: error: expected declaration before '}' token



Multiple libraries were found for "Wire.h"

Used: C:\Users\malthemail\Documents\Arduino\libraries\Wire

Not used: C:\Users\malthemail\Documents\Arduino\libraries\Robot_Control

Not used: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\Wire

Error compiling.

This report would have more information with

"Show verbose output during compilation"

enabled in File > Preferences.

SteveS17 made it!4 months ago

Its worth noting that there are two or three common pin mappings for the different I2C 1602 backpack boards out there. I just bought this one


and the mapping is different than the MJKDZ board in this Instructable. Mine needs the following:

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

This site has a good explanation of the different style boards and several example sketches for Arduino.


Note its possible with my variation of board to customize the address by bridging one or more of the A0, A1 & A2 pads, so you could have multiple LCDs with I2C at different addresses. The default with all pads open is 0x27 and all pads bridged gives 0x20.

A hugh thanks to

verdelj for posting the I2C Scanner code, that was a BIG help in working out how to configure my board!

Clement215 months ago

Hi Sir, what should I do if I'm using Arduino Nano?

verdelj (author)  Clement214 months ago

the sketch is the same the only thing is the pins that you are going to use, on most arduino nano the SCL is pin A5 and for SCA pion A4 you have tho look at the version that you have and connect it to the apropiate pins.

etype6 months ago

can someone please help me to setup a 24×3 lcd on my raspberry pi b+

it has 18 pins link to photo here http://www.etypetv.com/pi

i need pin outs for this display to raspberry pi b+

VasaS7 months ago

How did you find the pin values bellow?

#define En_pin 4
#define Rw_pin 5
#define Rs_pin 6
#define D4_pin 0
#define D5_pin 1
#define D6_pin 2
#define D7_pin 3

Are they the pin numbers on the actual controller that are plugged into the lcd?

If they are how did you find those values?

verdelj (author)  VasaS6 months ago

yes, I am using an lcd with a Hitachi HD44780 driver if you look at the picture with the pinout you will see the values.

JoseC78 months ago

a have mad all the steps,but dosen´t work...it say "no such file or directory"

verdelj (author)  JoseC78 months ago
Instala https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
JoseC78 months ago

Arduino: 1.5.8 (Windows 7), Placa:"Arduino Uno"

lcd1602.ino:9:17: fatal error: LCD.h: No such file or directory

compilation terminated.

Erro ao compilar.

Este relatório teria mais informação com

"Mostrar output verboso durante a compilação"

ativo em Ficheiro > Preferências

verdelj (author)  JoseC78 months ago
You need to install the library on the link
amri.jbi8 months ago

Excuse me, what about arduino uno, does programs it same?

verdelj (author)  amri.jbi8 months ago

the program is the same, all you have to do is connect SDA to pin A4 and SCL to pin A5 and it should work. on my is pin 20 and 21 because I am using arduino mega

Thank you for taking the time to put this together. I'm building a solar battery charger controller and the author deba168 recommended your Instructable to help with the LCD display in the unit.

orestman11 months ago

Why it shows that it does not find any devices? HELP!!! I inserted the scl AND the sda to the right position.I have the Arduino uno, but I changed the Serial.begin to 9600

verdelj (author)  orestman11 months ago

first thing to check is make sure have sda is connected to A4 and scl to A5 pm the arduino uno. Also make sure you have the correct l2c address for the module, you might want to upload the i2c scanner sketch. To find the address for your module then just modify the sketch.

diy_bloke1 year ago

i understand that the backlight polarity can be combined in the lcd initialisation:

lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin, POSITIVE);

verdelj (author)  diy_bloke1 year ago

Yes you are correct, its all about the efficiency of the code the way you have it it is much better and the way is suppose to be done. but for the lack of time and knowledge I used a different method. Thank you for pointing it out, if it wasn't for you I would have never given a second thought and looked at that library again. Thanks

amurzakhmetov made it!1 year ago

very useful!

MoonDocker1 year ago

Thanks for sharing this is valuable code. There are a lot of LCD's out there with little or no documentation. I have an Arduino Uno and the pin setup was SCL on A5 and the SDA on A4.

verdelj (author) 2 years ago
The scanner works great it found the module address 0X20. Usually is 0x20 or 0x27 but the I2C Scanner its a great tool to have.