🔍 Search on DIYTechStudio

Tuesday, July 21, 2020

How to connect 16*2 LCD Display using only 4 wires & I2C module to Arduino UNO (Method 2) - Arduino Tutorials #15

In this post, I will show you how to connect the 16*2 LCD Display Module to an Arduino UNO using only 4 wires & I2C module.

If you don't have an I2C module you can click here to read how to connect 16*2 display module to Arduino UNO without using the I2C module. I don't recommend using this method since this uses 8 Arduino Pins. Where has using I2C module you use only 4 pins to connect the 16*2 display

If you prefer video mode you can click here to watch it on YouTube.

First, mount the I2C module to the Arduino UNO. While mounting make sure the 4 pins leading to Arduino UNO is facing outside like shown in the below image


Next, connect the circuit according to the circuit diagram
Next, connect the circuit to a Laptop or a Desktop and open the Arduino IDE


Next, install the library "LiquidCrystal I2C" by Frank de Brabander



Next upload the sketch "HelloWorld" which is under File > Examples > LiquidCrystal I2C to test the circuit. 

After uploading if you don't see any character displayed adjust the brightness using the trimmer of the I2C module until you get the display



Sketch

Sketch Start

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

LiquidCrystal_I2C lcd(0x27,20,4);

void setup()
{
  lcd.init();
  lcd.backlight();
  lcd.setCursor(3,0);
  lcd.print("Hello, world!");
  lcd.setCursor(2,1);
  lcd.print("Ywrobot Arduino!");
}

void loop(){}
 
Sketch End

Sketch Explanation - Hello World

#include <Wire.h>Includes the library code for Wire which allows us to communicate with I2C devices
#include <LiquidCrystal_I2C.h> - Includes the library code for Liquid Crystal with I2C
LiquidCrystal_I2C lcd(0x27,20,4); -  Set the LCD address to 0x27 for a 16 chars (Columns) and 2 line display (Rows)
void setup() {} - Setup function runs when you power the board or press reset button. 
lcd.init(); - Initializes the lcd 
lcd.backlight(); - Turns On the Backlight
lcd.setCursor(3,0); - Sets the cursor to column 4, row 1 and then prints the next print statement 
lcd.print("Hello, world!"); - Prints Hello, world on the LCD Module
lcd.setCursor(2,1); - Sets the cursor to column 3, row 2 and then prints the next print statement 
lcd.print("Ywrobot Arduino!"); - Prints Ywrobot Arduino! on the LCD Module
void loop() {} - Loop function runs statements inside it over and over again forever

Affiliate Links

No comments:

Post a Comment

Hi, Thanks for Commenting !!!