LCD 2×16 I2C

Description

  • LCD screen with 2 rows of 16 characters
  • I2c communication enables you to power and communicate with the screen using only 4 wires
  • By changing the default I2C address you can run multiple LCDs on the same bus
  • Already installed contrast trim pot
  • Supports baud rates from 1200 to 200 kbps (default is 9600 bps)
  • Switchable backlight
  • Easy to use and set up

Easy to use LCD display with two 16-character lines. Power it directly from the Arduino 5V power pin and use I2C, communicating with only 2 data lines to send the information you want to display. Try our example sketch for auto I2C configuration and address display.

Supply voltage +5 VDC 120 mA
Size 2 lines, 16 characters
Backlight Blue, white characters
Default I2C address 27 (3F for version A)
Screen size 64 mm * 14 mm
Posible I2C addresses for IC A2** A1** A0** Address
VSS VSS VSS 38h
VSS VSS VDD 39h
VSS VDD VSS 3Ah
VSS VDD VDD 3Bh
VDD VSS VSS 3Ch
VDD VSS VDD 3Dh
VDD VDD VSS 3Eh
(pads on the back get shortened to ground)

Easy to connect, with only four cables. You can pin the module on the breadboard and use the male to male jumper cables, or use the male to female jumper cables to connect the module directly to the Arduino-compatible board.

To supply voltage to the board, connect the VCC pin to the 5v power pin and the GND pin to the GND pin. If you want to use an external power supply, be sure to connect the grounds together. Connect SDA to A4 and SCL to A5 on your Arduino-compatible board.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
by Dr. Mangus from Mango Labs
  
Scanning code by Arduino.cc user Krodal and louarnold
 
tested on Arduino enviroment 1.8.5
 
needs LiquidCrystal_PCF8574 library and
included Wire library
**/
#include <Wire.h>
#include <LiquidCrystal_PCF8574.h>
 
 
 
int show;
int lcdi2c = 0x0;
void setup()
{
  byte error, address;
  int nDevices;
 Wire.begin();
  Serial.begin(9600);
  Serial.println("LCD I2C Scanner");
//scanning I2C address
 nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
  
    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
      lcdi2c = address;
      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknown error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }   
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");
  //scanning end
   
LiquidCrystal_PCF8574 lcd(lcdi2c);  // autoset the LCD address
 
  lcd.begin(16, 2); // initialize the lcd
  lcd.setBacklight(255);
  show = 0;
} // setup()
 
void loop()
{
   
  LiquidCrystal_PCF8574 lcd(lcdi2c);  // autoset the LCD address
 
  lcd.setBacklight(255);
  if (show == 0) {
    lcd.home(); lcd.clear();
    lcd.print("Hello LCD");
    lcd.setCursor(0, 1);
    lcd.print("Your i2C add: ");
    lcd.print(lcdi2c,HEX);
    delay(1000);
 
    
  } else if (show == 1) {
    lcd.clear();
    lcd.print("Cursor On");
    lcd.cursor();
 
  } else if (show == 2) {
    lcd.clear();
    lcd.print("Cursor Blink");
    lcd.blink();
 
  } else if (show == 3) {
    lcd.clear();
    lcd.print("Cursor OFF");
    lcd.noBlink();
    lcd.noCursor();
 
  } else if (show == 4) {
    lcd.clear();
    lcd.print("Display Off");
    lcd.setBacklight(0);
    lcd.noDisplay();
 
  } else if (show == 5) {
    lcd.clear();
    lcd.print("Display On");
    lcd.display();
 
  } else if (show == 7) {
    //lcd.setBacklight(255);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("***Mango Labs***");
    lcd.setCursor(0, 1);
    lcd.print("**Mango* *Labs**");
 
  } else if (show == 8) {
    lcd.scrollDisplayLeft();
  } else if (show == 9) {
    lcd.scrollDisplayLeft();
  } else if (show == 10) {
    lcd.scrollDisplayLeft();
  } else if (show == 11) {
    lcd.scrollDisplayRight();
  } // if
 
  delay(2000);
  show = (show + 1) % 12;
}
  1. In this example we are connecting:
    Arduino  LCD
    A4     — SDA
    A5     — SCL
    GND — GND
    5V     — VCC
  2. Download and install the Arduino environment from here or use the web editor.
  3. Download the Arduino library for the LCD  here.
  4. Unzip and paste the folder in the Arduino libraries folder. It’s in the same location as your default sketches. To find the sketchbook location, go to File /Preferences
  5. Download this sketch and open or open the Arduino environment and copy the code into a blank sketch.
  6. Connect your board to your computer with the included USB cable.
  7. Select your board in Tools / Board / Arduino Uno.
  8. Select your port in Tools / Port / COM# (Arduino Uno). This may be slightly different depending on your operating system.
  9. Upload by pressing the arrow in the circle to the upper left.
  10. Check if anything is happening on your LCD screen. If the screen is too dark or too bright, turn the trim pot on the back with a small screwdriver until you achieve good contrast.