How to use the 1602 LCD w/ i2C with Arduino

How to use the 1602 LCD w/ i2C with Arduino

1602 LCD for Arduino

INTRODUCTION

1602 Character-type liquid crystal display (LCD) is a kind of dot matrix module to display letters, numbers, and characters. It is composed of 16 characters long by 2 characters tall “sections” that can be programed to display letter characters or shapes.

APPLICATIONS

It is used in robotics to show various readings from sensors and can also provide a form of graphical user interface. You can find LCD displays in your car which shows maps, showing current audio/video title, and other control options for the vehicle.

WIRING DIAGRAM

(note ignore the blue wires - the i2c backpack is already connected to the LCD)

1602 LCD  i2C with Arduino

The I2C module and the screen are separated in the diagram but yours is already connected. You can follow the connections of the four wires (GND, VCC, SCA and SCL). Wiring connections are SCA to A4 and SCL to A5 for the Uno board. On the Mega, you will see SCA and SCL write no the digital input side of the board.

Note: Download the required library and follow these steps.

Now you would need to find the address of your LCD. See below.

CODE 1

To find your i2C address, copy the code below and paste in the Arduino IDE:

#include <Wire.h>

void setup() {
  Serial.begin (9600);
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 8; 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 (")");
      count++;
      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() {}

Open the serial monitor and obtain your i2c address and paste the address in the code below under 

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

CODE 2

To print characters to your LCD, use code below. Note you will have to add in the LCD address that was obtained from code above.

 

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

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

void setup()
{
  lcd.begin(16,2);
  lcd.backlight();                     
    
}

void loop()
{
  lcd.backlight(); 
  lcd.setCursor(0,0);
  lcd.print("  MONSTER IS");
  lcd.setCursor(0,1);
  lcd.print("    ONLINE");
}

END RESULT

The LCD will display “MONSTER IS” on the first line and “ONLINE” on the second line. You can also adjust the light brightness on the blue potentiometer on the back of the LCD.

ADDITIONAL RESOURCES

https://www.instructables.com/id/Connecting-a-4-x-4-Membrane-Keypad-to-an-Arduino/