LCD 20×4 Arduino I2C Code Basic Tutorial

Posted on

LCD I2C 20×4 Arduino

How to use LCD 20×4 Arduino I2C? – This LCD is very popular after the 16×2 LCD. One of the most current uses is on Prusa 3D Printers.

The use of the 20×4 LCD is very easy with the help of the Arduino library, both for displaying text and characters.

A value of 20×4 means that this LCD consists of 20 20 characters and 4 rows.

This 20×04 LCD uses Arduino to communicate with Arduino in 2 ways. The first is 8-bit parallel communication and the second is I2C serial communication.

In this tutorial we will learn how to display HAMBO ELECTRONIK TEST 20×04 LCD using Arduino.

Libary liquidcrystal_i2c

First download the LiquidCrysta_I2Cl library, then we will display the words “HAMBO ELEKTRONIK” on the first line and on the third line, we will display the words TEST LCD 20×4.

Download LiquidCrystal_I2C Libary

After friends download, open Arduino IDE:

  • Click Sketch > Include Library > Add .ZIP Library
  • Enter the LiquidCrystal_I2C library that have downloaded
  • Click File > Example
  • If the LiquidCrystal_I2C list appears, it means that the library has entered the Arduino IDE


Before Arduino is programmed, make the circuit first as shown in the image below.

Arduino LCD 20×4
5V > VCC
A4 > SDA
A5 > SCL

LCD 20x4 Arduino I2C Code Basic Tutorial

Scan I2C Address

After you have assembled like the picture above, we must know the I2C address of the LCD. To be able to find out the address, we scan first.

The trick is to program the Arduino with the program below, then open the serial monitor. The I2C address will appear from the LCD.

Please use this code:

#include <Wire.h>

void setup() {
  Serial.begin (9600);
  while (!Serial) 
  Serial.println ();
  Serial.println ("Search I2C Address ...");
  byte count = 0;
  for (byte i = 8; i <120; i++)
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      Serial.println ("get it");
      Serial.print ("Address is: ");
      Serial.print ("0x");
      Serial.println (i, HEX);
      delay (1);  
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" Device.");
void loop() {}

Displaying Text on LCD

From the program above, I get the result that the ID address of this LCD is 0x3F. This address is what we will enter into the program so that it can display the writing of the 20×4 LCD . Upload the program below to Ardunino.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x3F, 20, 4); 

void setup()
  lcd.setCursor(0, 0);
  lcd.print("    Hello World!");
  lcd.setCursor(0, 2);

void loop()

Result is:

LCD 20x4 Arduino I2C

Good luck and I hope this article is useful. Want to share? Please use the share button below.

Leave a Reply

Your email address will not be published.