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.
Remove these adsRemove these ads by Signing Up

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)    


Step 2: Soldering

Picture of Soldering
Now we solder the LCD and the controller. make sure you have the correct pin arrangement. Mine doesn't have a mark for pin one, but I just looked at the 5+ and GND inputs to figure it out.

Step 3: Connecting

Picture of Connecting
it is very simple to connect only 4 wire 5+ and GND and  SDA goes to Arduino pin 20 and SCL to pin 21 on my arduino mega. depending on what you have it might be different.

Step 4: The Code

Picture of The Code
Since the seller doesn't provide any info I neede to find the address for the module so I ran an I2C scanner
 //Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

void setup() {
  Serial.begin (115200);

  // Leonardo: wait for serial port to connect
  while (!Serial)

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  for (byte i = 1; i < 120; i++)
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}
etype1 month 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

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

VasaS1 month 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)  VasaS1 month 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.

JoseC73 months ago

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

verdelj (author)  JoseC73 months ago
JoseC73 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)  JoseC73 months ago
You need to install the library on the link
amri.jbi3 months ago

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

verdelj (author)  amri.jbi3 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.

orestman5 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)  orestman5 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_bloke9 months 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_bloke9 months 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) 1 year 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.