Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
85 views

Arduino Info LCD Blue I2C

This document provides information about LCD displays with an I2C interface that can connect to an Arduino board using only 2 pins. It discusses three versions of the displays that have different labels on the interface board. It provides example code for initializing and writing text to the displays. The code samples demonstrate using the LiquidCrystal_I2C library to control the displays from the Arduino IDE.

Uploaded by

Rhedan Polo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views

Arduino Info LCD Blue I2C

This document provides information about LCD displays with an I2C interface that can connect to an Arduino board using only 2 pins. It discusses three versions of the displays that have different labels on the interface board. It provides example code for initializing and writing text to the displays. The code samples demonstrate using the LiquidCrystal_I2C library to control the displays from the Arduino IDE.

Uploaded by

Rhedan Polo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

3/12/2018 arduino-info - LCD-Blue-I2C

LCD-Blue-I2C (/LCD-Blue-I2C)
 Edit  24 (/LCD-Blue-I2C#discussion)  121 (/page/history/LCD-Blue-I2C) … (/page/menu/LCD-Blue-I2C)

LCD Displays (Blue and Yellow) with I2C/TWI Interface

IMPORTANT LCD Software Library Info:

ALL these displays will now use the great Library


written by F Malpartida . You should download that
Library HERE (Click) (Get the latest file such as
NewliquidCrystal_1.3.4.zip )
If you try to Verify and you see this:
error: 'LiquidCrystal_I2C' does not name a type
...this means you do not have the library installed correctly. See:
How-To-Install-Libraries
NOTE!! Move any other LCD libraries to another folder,or rename or delete them.

NOTE! THERE ARE THREE (or More??) VERSIONS OF THE 2 and 4 LINE DISPLAYS. Check the
small "backpack" interface board on the back. These small circuit boards on the back interface a 2-
wire I2C "I Squared C" bus (plus Ground and +5V power) to the many pins on the LCD display itself.
This allows running the display from only 2 signal pins on Arduino. The YourDuino RoboRED (UNO
Compatible) has a 4-pin connector that works well for this type display.

LCD Version 1 - Marked "YwRobot Arduino LCM1602 IIC V1" ALSO version marked "A0 A1 A2" on
lower right (and also labelled "MH")
LCD Version 2 - Marked "Arduino-IIC-LCD GY-LCD-V1"
LCD Version 3 - Marked "LCM1602 IIC A0 A1 A2"

These displays are Available HERE:


NOTE! These displays are very clear bright white on dark blue (or Black on Yellow) background: it is
difficult to get a good digital photo due to polarization effects.

NOTE! I2C ADDRESSES:

I2C Address Scanner Sketch HERE


The "backpack" modules used on these displays utilize PCF8574A IC Chip. The Datasheet is HERE:
pcf8574a.pdf
Details Download 1 MB

The modules used on these displays may also be used for general-purpose 8-bit I/O expanders. A
module with the address pins available is HERE
These I2C interface displays have a built-in ADDRESS. If you try to run a display and there is no
response or nothing is displayed you may have the wrong address in the code you are using. You can
run the I2C ADDRESS SCANNER (Bottom of this page) on your Arduino to check the address on

https://arduino-info.wikispaces.com/LCD-Blue-I2C 1/17
3/12/2018 arduino-info - LCD-Blue-I2C

your display if necessary. For LOTS of detailed technical information about I2C Interfaces see
THIS from Nick Gammon.

WHY THE I2C (IIC) TYPE LCD DISPLAY?


To use this type LCD directly with Arduino, you would need 6 pins: RS, EN, D7, D6, D5, and D4 to
talk to the LCD. If you are doing more than a simple project, you may be out of pins using a normal
LCD shield. With this I2C interface LCD module, you only need 2 lines (I2C) to display information.
If you already have I2C devices in your project, this LCD module actually uses no more pins at all.
More information about I2C/TWI (Wikipedia)
This unit connects with 4 wires including Vcc and Gnd. It is easiest with a 4-wire cable that plugs
into the Sensor Shield communications connector or directly to a YourDuino RoboRED (UNO
Compatible: See it HERE (click))..

But you can wire it directly yourself if needed: There are 4 pins on the display.. (see photo below)

Top to bottom:
GND - GND
VCC - 5V
SDA -
SCL -
UNO MEGA
SDAAnalog 4Pin 20
SCL Analog 5Pin 21

On most Arduino boards, SDA (data line) is on analog input pin 4, and SCL (clock line) is on analog
input pin 5. On the newer Arduino UNO (The "V3" pinout), the SCL and SDA pins are also on two
new leftmost top pins. The YourDuino RoboRED has those pins and also a nice 4-pin connector
arranged exactly like the LCD display pins.
On the Arduino Mega, SDA is digital pin 20 and SCL is pin 21.
NOTE: The Blue Potentiometer (Photo) adjusts Contrast. If you don't see any characters, adjust
it. Start clockwise and back down to where the characters are bright and the background does not
have boxes behind the characters.

See a LCD used in the Temperature-Humidity project.

LiquidCrystal_I2C Library Support Functions


See the "Docs" folder within the Library folder. There are many advanced functions.

Below are Example Software Sketches for different displays. They will display characters you type
on the Serial Monitor screen on the LCD. NOTE: Line 1 only is correct when writing a long sequence
https://arduino-info.wikispaces.com/LCD-Blue-I2C 2/17
3/12/2018 arduino-info - LCD-Blue-I2C

of characters. The characters fill the first line and continue on the third, due to the way the LCD
internal addressing works. So this is "normal" and has to do with the LCD hardware. Usually you will
set the cursor position before writing characters. (Details in the document linked at the end of this
page, if you want them.)
(Cut and paste these examples into a blank page on the Arduino IDE).

I2C LCD DISPLAY VERSION 1:


Example Software Sketch for 2 line 16
character Displays:
(NOTE: for displays with backpack interface
labelled "YwRobot Arduino LCM1602 IIC V1")
See photo Above.
(NOTE: Also for displays with backpack
interface labelled "A0 A1 A2" photo: right).
(NOTE: Most displays use I2C Adress 0x27
but a FEW (Including those labelled "MH" ) use 0x3F (Change in code below)

/* YourDuino.com Example Software Sketch


16 character 2 line I2C Display
Backpack Interface labelled "A0 A1 A2" at lower right.
..and
Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
MOST use address 0x27, a FEW use 0x3F
terry@yourduino.com */

/*-----( Import needed libraries )-----*/


#include <Wire.h> // Comes with Arduino IDE
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>

/*-----( Declare Constants )-----*/


/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 16 chars 2 line display
// A FEW use address 0x3F
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

/*-----( Declare Variables )-----*/


//NONE

void setup() /*----( SETUP: RUNS ONCE )----*/


{
Serial.begin(9600); // Used to type in characters

lcd.begin(16,2); // initialize the lcd for 16 chars 2 lines, turn on backlight

// ------- Quick 3 blinks of backlight -------------


for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
lcd.backlight(); // finish with backlight on

https://arduino-info.wikispaces.com/LCD-Blue-I2C 3/17
3/12/2018 arduino-info - LCD-Blue-I2C

//-------- Write characters on the display ------------------


// NOTE: Cursor Position: (CHAR, LINE) start at 0
lcd.setCursor(0,0); //Start at character 4 on line 0
lcd.print("Hello, world!");
delay(1000);
lcd.setCursor(0,1);
lcd.print("HI!YourDuino.com");
delay(8000);

// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
lcd.clear();
lcd.setCursor(0,0); //Start at character 0 on line 0
lcd.print("Use Serial Mon");
lcd.setCursor(0,1);
lcd.print("Type to display");

}/*--(end setup )---*/

void loop() /*----( LOOP: RUNS CONSTANTLY )----*/


{
{
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
}
}

}/* --(end main loop )-- */

/* ( THE END ) */

Example Software Sketch for 4 line 20 character Displays:


(NOTE: for displays with backpack interface labelled "YwRobot Arduino LCM1602 IIC V1")
(NOTE: Also for displays with backpack interface labelled "A0 A1 A2" photo: right).
(NOTE: Most displays use I2C Adress 0x27 but a FEW (Including those labelled "MH" ) use 0x3F
(Change in code below)

/* YourDuino.com Example Software Sketch


20 character 4 line I2C Display
Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
Connect Vcc and Ground, SDA to A4, SCL to A5 on Arduino
terry@yourduino.com */

/*-----( Import needed libraries )-----*/


#include <Wire.h> // Comes with Arduino IDE
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>

https://arduino-info.wikispaces.com/LCD-Blue-I2C 4/17
3/12/2018 arduino-info - LCD-Blue-I2C

/*-----( Declare Constants )-----*/


/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

/*-----( Declare Variables )-----*/

void setup() /*----( SETUP: RUNS ONCE )----*/


{
Serial.begin(9600); // Used to type in characters

lcd.begin(20,4); // initialize the lcd for 20 chars 4 lines, turn on backlight

// ------- Quick 3 blinks of backlight -------------


for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
lcd.backlight(); // finish with backlight on

//-------- Write characters on the display ------------------


// NOTE: Cursor Position: Lines and Characters start at 0
lcd.setCursor(3,0); //Start at character 4 on line 0
lcd.print("Hello, world!");
delay(1000);
lcd.setCursor(2,1);
lcd.print("From YourDuino");
delay(1000);
lcd.setCursor(0,2);
lcd.print("20 by 4 Line Display");
lcd.setCursor(0,3);
delay(2000);
lcd.print("http://YourDuino.com");
delay(8000);
// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
lcd.setCursor(0,0); //Start at character 0 on line 0
lcd.print("Start Serial Monitor");
lcd.setCursor(0,1);
lcd.print("Type chars 2 display");

}/*--(end setup )---*/

void loop() /*----( LOOP: RUNS CONSTANTLY )----*/


{
{
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
}
}

}/* --(end main loop )-- */

https://arduino-info.wikispaces.com/LCD-Blue-I2C 5/17
3/12/2018 arduino-info - LCD-Blue-I2C

/* ( THE END ) */

I2C LCD DISPLAY VERSION 2:


Marked "Arduino-IIC-LCD GY-LCD-V1"
NOTE: The wire connections are in a
different order! See the labels on the PC
Board.

NEW TYPE 4 line 20 character


Displays: Example Software Sketch

/* YourDuino.com Example Software Sketch


20 character 4 line I2C Display
Backpack Interface labelled "LCM1602 IIC A0 A1 A2"
terry@yourduino.com */

/*-----( Import needed libraries )-----*/


#include <Wire.h> // Comes with Arduino IDE
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>

/*-----( Declare Constants )-----*/


//none
/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x20, 4, 5, 6, 0, 1, 2, 3, 7, NEGATIVE); // Set the LCD I2C address

/*-----( Declare Variables )-----*/


//none

void setup() /*----( SETUP: RUNS ONCE )----*/


{
Serial.begin(9600); // Used to type in characters

lcd.begin(20,4); // initialize the lcd for 20 chars 4 lines

// NOTE: Cursor Position: CHAR, LINE) start at 0


lcd.setCursor(3,0); //Start at character 4 on line 0
lcd.print("Hello, world!");
delay(1000);
lcd.setCursor(2,1);
lcd.print("From YourDuino");
delay(1000);
lcd.setCursor(0,2);
lcd.print("20 by 4 Line Display");
lcd.setCursor(0,3);
delay(2000);
lcd.print("http://YourDuino.com");
delay(8000);
// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
lcd.setCursor(0,0); //Start at character 0 on line 0
lcd.print("Start Serial Monitor");

https://arduino-info.wikispaces.com/LCD-Blue-I2C 6/17
3/12/2018 arduino-info - LCD-Blue-I2C
lcd.setCursor(0,1);
lcd.print("Type chars 2 display");

}/*--(end setup )---*/

void loop() /*----( LOOP: RUNS CONSTANTLY )----*/


{
{
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
}
}

}/* --(end main loop )-- */

/* ( THE END ) */

I2C LCD DISPLAY VERSION 3:


This has Yet Another I2C board type marked "LCM1602 IIC A0 A1 A2" (Photo)

NOTE: Some of this type board come with the A0 A1 A2 connections (See photo) that are NOT
bridged with solder as in the photo. Those will have address 0x27 not address 0x20. For that
version you need to change the sketch example below.

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


MUST BE CHANGED TO:
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

You need the same new library in the section above.


Here's an example Software Sketch that works with this display. Copy this and paste into blank
Arduino IDE window. Verify (Need the library above installed), then upload.

https://arduino-info.wikispaces.com/LCD-Blue-I2C 7/17
3/12/2018 arduino-info - LCD-Blue-I2C

/* YourDuino.com Example Software Sketch


20 character 4 line I2C Display
Backpack Interface labelled "LCM1602 IIC A0 A1 A2"
terry@yourduino.com */

/*-----( Import needed libraries )-----*/


#include <Wire.h> // Comes with Arduino IDE
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>

/*-----( Declare Constants )-----*/


//none
/*-----( Declare objects )-----*/
// set the LCD address to 0x20 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x20, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

/*-----( Declare Variables )-----*/


//none

void setup() /*----( SETUP: RUNS ONCE )----*/


{
Serial.begin(9600); // Used to type in characters

lcd.begin(20,4); // initialize the lcd for 20 chars 4 lines and turn on backlight

// ------- Quick 3 blinks of backlight -------------


for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
lcd.backlight(); // finish with backlight on

//-------- Write characters on the display ----------------


// NOTE: Cursor Position: CHAR, LINE) start at 0
lcd.setCursor(3,0); //Start at character 4 on line 0
lcd.print("Hello, world!");
delay(1000);
lcd.setCursor(2,1);
lcd.print("From YourDuino");
delay(1000);
lcd.setCursor(0,2);
lcd.print("20 by 4 Line Display");
lcd.setCursor(0,3);
delay(2000);
lcd.print("http://YourDuino.com");
delay(8000);
// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
lcd.setCursor(0,0); //Start at character 0 on line 0
lcd.print("Start Serial Monitor");
lcd.setCursor(0,1);
lcd.print("Type chars 2 display");

}/*--(end setup )---*/

void loop() /*----( LOOP: RUNS CONSTANTLY )----*/


{
{
// when characters arrive over the serial port...
if (Serial.available()) {

https://arduino-info.wikispaces.com/LCD-Blue-I2C 8/17
3/12/2018 arduino-info - LCD-Blue-I2C
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
}
}

}/* --(end main loop )-- */

/* ( THE END ) */

I2C ADDRESS SCANNER FOR ARDUINO/YOURDUINO:


You can scan for the I2C address used by your display. Connect your display (See connection info at
top of this page). Then upload the following sketch to your Arduino. Click on "Serial Monitor at
upper right. Set the Speed (lower right pulldown) to 115200. Push the Reset button on your
Arduino and see the results. The results should look like this (address changes):

I2C scanner. Scanning ...


Found address: 39 (0x27)
Done.
Found 1 device(s).
 

Copy and Paste this sketch (Thanks Nick Gammon!) into a blank Arduino IDE window:

// 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;

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");

https://arduino-info.wikispaces.com/LCD-Blue-I2C 9/17
3/12/2018 arduino-info - LCD-Blue-I2C
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() {}

CHANGING I2C ADDRESSES:

SOME I2C interfaces have pins (or solder pads) that can be changed to change the address. They
are usually labelled A0-A1-A2 . Here's the way addresses change from a default 0x27 with if you
connect address pads together. (1 = Not Connected. 0 = Connected):

A0A1A2HEX Address
1 1 1 0x27
0 1 1 0x26
1 0 1 0x25
0 0 1 0x24
1 1 0 0x23
0 1 0 0x22
1 0 0 0x21
0 0 0 0x20

If you make a change use the I2C Address Scanner to confirm it...

Detailed information about LCD displays from Donald Weiman (weimandn@alfredstate.edu)


LCD Addressing.pdf
Details Download 251 KB

MORE INFORMATION ABOUT THE I2C "BACKPACK" USED ON THESE DISPLAYS:


Schematic Diagram:

https://arduino-info.wikispaces.com/LCD-Blue-I2C 10/17
3/12/2018 arduino-info - LCD-Blue-I2C

PCF8574/PCF8574A DATA SHEET


PCF8574_PCF8574A-842013.pdf
Details Download 816 KB

(https://www.wikispaces.com/user/view/garybarbieri)
is there a liberary for mapel mini? 
garybarbieri (https://www.wikispaces.com/user/view/garybarbieri) Jul 13, 2017

I am looking for an lcd library for the maple mini$

(https://www.wikispaces.com/user/view/ogun)
Problem with Smraza 2004 LCD Display Module (20 characters x 4 lines) for Arduino 
MEGA2560
ogun (https://www.wikispaces.com/user/view/ogun) Apr 4, 2017

Hello guys, I need your help on a code or LCD display. I am using the MEGA2560 with
LCD address 0x27. SCL PIN 21 AND SDA PIN 20. when I compile the code it works fine,
the only problem is it only shows one letter in each row. For example instead of showing
"Hello world" it only shows "H" or in this code
"W
A
T
1" or only the first letter in each row.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4); set the LCD address to: (0x3F Smraza) or (0x27
HiLetGo, Sainsmart & Sunfounder) for a 20 chars and 4 line display

void setup()
{
lcd.init(); initialize the lcd
lcd.backlight();
lcd.setCursor(0,0);// first number is position, second is row
lcd.print("Welcome 2 Ur LCD :)");
lcd.setCursor(0,1);

https://arduino-info.wikispaces.com/LCD-Blue-I2C 11/17
3/12/2018 arduino-info - LCD-Blue-I2C
lcd.print("Arduino & LCM IIC 2004");
lcd.setCursor(0,2);
lcd.print("Testing with Nano");
lcd.setCursor(0,3);
lcd.print("123456789ABCDEFGHIJK");
}

void loop()
{
}

(https://www.wikispaces.com/user/view/TerryKing) TerryKing
(https://www.wikispaces.com/user/view/TerryKin
Apr 8, 2017
Hi,
Try the code HERE:
https://arduino-info.wikispaces.com/LCD-
Blue-I2C (https://arduino-
info.wikispaces.com/LCD-Blue-I2C)
Let me know....
Regards, Terry King
...In The Woods in Vermont, USA
terry@yourduino.com
(mailto:terry@yourduino.com)

(https://www.wikispaces.com/user/view/jpalacios84)
Problem solving 
jpalacios84 (https://www.wikispaces.com/user/view/jpalacios84) Jan 30, 2017

please Friends add the next script on void setup

Wire.begin();

This is the command required to display on the screen

Full script:

#include <Wire.h> Comes with Arduino IDE


Get the LCD I2C Library here:
https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
(https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads)
Move any other LCD libraries to another folder or delete them
See Library "Docs" folder for possible commands etc.
#include <LiquidCrystal_I2C.h>
int POSITIVE = 1;
/*-----( Declare Constants )-----*/
/*-----( Declare objects )-----*/
set the LCD address to 0x27 for a 16 chars 2 line display
A FEW use address 0x3F
Set the pins on the I2C chip used for LCD connections:
addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x3F,16,2); Set the LCD I2C address

/*-----( Declare Variables )-----*/


NONE

void setup() /*----( SETUP: RUNS ONCE )----*/


{
Wire.begin ();
Serial.begin(9600); Used to type in characters

lcd.begin(16,2); initialize the lcd for 16 chars 2 lines, turn on backlight

------- Quick 3 blinks of backlight -------------


https://arduino-info.wikispaces.com/LCD-Blue-I2C 12/17
3/12/2018 arduino-info - LCD-Blue-I2C
for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
lcd.backlight(); finish with backlight on

-------- Write characters on the display ------------------


NOTE: Cursor Position: (CHAR, LINE) start at 0
lcd.setCursor(0,0); Start at character 4 on line 0
lcd.print("Hello, world!");
delay(1000);
lcd.setCursor(0,1);
lcd.print("HI!YourDuino.com");
delay(3000);

Wait and then tell user they can start the Serial Monitor and type in characters to
Display. (Set Serial Monitor option to "No Line Ending")
lcd.clear();
lcd.setCursor(0,0); Start at character 0 on line 0
lcd.print("Use Serial Mon");
lcd.setCursor(0,1);
lcd.print("Type to display");

}/*--(end setup )---*/

void loop() /*----( LOOP: RUNS CONSTANTLY )----*/


{
{
when characters arrive over the serial port...
if (Serial.available()) {
wait a bit for the entire message to arrive
delay(100);
clear the screen
lcd.clear();
read all the available characters
while (Serial.available() > 0) {
display each character to the LCD
lcd.write(Serial.read());
}
}
}

}/* --(end main loop )-- */

/* ( THE END ) */

(https://www.wikispaces.com/user/view/renssii)
error in the program 
renssii (https://www.wikispaces.com/user/view/renssii) Jan 5, 2017

Hello,
When i scannened my I2C with LCD with the adress scanner i got the number 0x3F
back, this wasn't such a big problem to change in my program.
But for the 'LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); Set the LCD
I2C address' code i got multiple errors, the first one was the POSITIVE and after that
the other numbers became the second problem
Only when i used this line 'LiquidCrystal_I2C lcd(0x3F, 16,2); Set the LCD I2C address'
both errors disapearred, but i couldn't get the arduino uno write anything on my LCD
https://arduino-info.wikispaces.com/LCD-Blue-I2C 13/17
3/12/2018 arduino-info - LCD-Blue-I2C
How do i get this to work?
thanks in advance
Rens

(https://www.wikispaces.com/user/view/TerryKing) TerryKing
(https://www.wikispaces.com/user/view/TerryK
Jan 11, 2017
Hi, Can you compile the code at "I2C LCD
DISPLAY VERSION 1:" on page
"http://arduino-info.wikispaces.com/LCD-
Blue-I2C (http://arduino-
info.wikispaces.com/LCD-Blue-I2C)" ??
You need to get that to compile first. Make
sure you have the right library
downloaded and installed. REMOVE any
other LCD libraries in your 'libraries' folder.
AFTER that compiles OK, change the
0x27 to 0x3F and compile and test that..
Let me know.. Better to email
terry@yourduino.com
(mailto:terry@yourduino.com)

(https://www.wikispaces.com/user/view/jessey7)
won't compile 
jessey7 (https://www.wikispaces.com/user/view/jessey7) Aug 28, 2016

Hello,
I'm trying to compile the code for the I2C and I get an error saying 'POSITIVE' was not
declared in this scope. Could anyone please advise me as to what could be causing
this error?
Thanks in advance
jessey

(https://www.wikispaces.com/user/view/MYTraveler) MYTraveler
(https://www.wikispaces.com/user/view/MY
Oct 23, 2016
I had the same problem. I ended up
replacing the many arguments in that
line of code with the 3-argument
version -- address, # of columns, # of
rows), and it compiled fine. But the
print commands did not work correctly
-- it just sprayed a few characters
around the display. I solved that by
printing one character at a time (simple
function for that). Any ideas on why?

(https://www.wikispaces.com/user/view/MYTraveler) MYTraveler
(https://www.wikispaces.com/user/view/MY
Oct 23, 2016
I had the same problem. I ended up
replacing the many arguments in that
line of code with the 3-argument
version -- address, # of columns, # of
rows), and it compiled fine. But the
print commands did not work correctly
-- it just sprayed a few characters
around the display. I solved that by
printing one character at a time (simple
function for that). Any ideas on why?

(https://www.wikispaces.com/user/view/shoemakerlevy9) shoemakerlevy9
(https://www.wikispaces.com/user/vie
Nov 3, 2016
I had the same issue. It was
because I was using the old
library. Look at the top of this

https://arduino-info.wikispaces.com/LCD-Blue-I2C 14/17
3/12/2018 arduino-info - LCD-Blue-I2C
page for a link to the new library
newliquidCrystal_1.3.4.zip

(https://www.wikispaces.com/user/view/Uvf53XoYdq8)
Pin-out change needed for Arduino Due 
Uvf53XoYdq8 (https://www.wikispaces.com/user/view/Uvf53XoYdq8) Jun 9, 2016

SDA and SLC on an Arduino DUE are pins 20 and 21 respectively - NOT A4 &
A5. I spent 3 days figuring this out, after thinking the LCD is dead. Maybe the
owner can add this great document.

(https://www.wikispaces.com/user/view/ROBERTOCARLOSALVARENGA)
86DUINO 
ROBERTOCARLOSALVARENGA
(https://www.wikispaces.com/user/view/ROBERTOCARLOSALVARENGA)
Apr 22, 2016

Hi, these libraries are compatible with 86duino board?


Is there any that you know?
Could you send me?
With the Arduino board (Uno, Mega ...) has no problems.
When I try to use the 86duino board, the sketch does not
compile.
I've tried several versions of I2C, without success.
thank you
http://www.86duino.com/?page_id=11
(http://www.86duino.com/?page_id=11)

(https://www.wikispaces.com/user/view/jh3141)
Other variants? 
jh3141 (https://www.wikispaces.com/user/view/jh3141) Apr 11, 2016

I'm sure there must be other variants of the I2C module, as F Malpartida's original code
is using a pin selection that isn't described on this page (it defaults to 6,5,4,0,1,2,3 with
no backlight pin). Any idea what these modules look like?

(https://www.wikispaces.com/user/view/VincentPalagi)
Instruction Set 
VincentPalagi (https://www.wikispaces.com/user/view/VincentPalagi) Mar 29, 2016

where can the instruction set for the library be found?


I have reviewed this topic and there is no place I can find the complete
instruction set other than
lcd.setCursor
lcd.print

(https://www.wikispaces.com/user/view/jh3141) jh3141
(https://www.wikispaces.com/user/view/jh
Apr 11, 2016
The full documentation is at
https://bitbucket.org/fmalpartida/new-
liquidcrystal/wiki/Home
(https://bitbucket.org/fmalpartida/new-
liquidcrystal/wiki/Home)

(https://www.wikispaces.com/user/view/KixMan)
Great help 
KixMan (https://www.wikispaces.com/user/view/KixMan) Nov 27, 2015

Thank you for this topic. It helped me a lot to get familiar with my I2C display.

https://arduino-info.wikispaces.com/LCD-Blue-I2C 15/17
3/12/2018 arduino-info - LCD-Blue-I2C

(https://www.wikispaces.com/user/view/alexela) alexela
(https://www.wikispaces.com/user/view/alexela)
Feb 6, 2016
Hey! awesome tutorial! Very very useful.
I'm having a problem. I have LCD v3.
bought from ali.
I can blink it on and off, but no letters.
It's 16x2 display on 0x27 address.
Cannot understand whats wrong.
Thanks a lot again.

(https://www.wikispaces.com/user/view/alexela) alexela
(https://www.wikispaces.com/user/view/alexela)
Feb 6, 2016
So stupid! it was a problem of contrast.
But I have another problem:
lcd.print("test"); - gives me only "t" not
whole word.
What can it be?
Thanks

(https://www.wikispaces.com/user/view/Alex_0_0) Alex_0_0
(https://www.wikispaces.com/user/view/Alex_
Feb 7, 2016
Hi,alexela !
download portable version Arduino 1.6.5
and you problem decided.
(https://www.arduino.cc/en/Main/OldSoftw
(https://www.arduino.cc/en/Main/OldSoftw

(https://www.wikispaces.com/user/view/napieram) napieram
(https://www.wikispaces.com/user/view/napie
Feb 22, 2016
Hahaha same problem with the display's
contrast ;)
Thanks for the tutorial!!!

(https://www.wikispaces.com/user/view/tekkenhead) tekkenhead
(https://www.wikispaces.com/user/view/tek
Mar 20, 2016
I am using 12c display version 1
example 4x16. The problem I am
running into is that
lcd.write(Serial.read()); function. When
typing in the serial monitor the input
skips every other line when being
displayed. Its going column1 to 3 to 2
to 4. Thanks.

(https://www.wikispaces.com/user/view/janVT1100) janVT1100
(https://www.wikispaces.com/user/view/janV
Apr 28, 2017
Hi I have Arduino Mega 2560 r3 and
LCD V1 above ... I did everyting as is
described (I2C scanner showing
0X3F)... but still can not display noting...
Can you advice me?

(https://www.wikispaces.com/user/view/vdprao) vdprao
(https://www.wikispaces.com/user/view/vdprao)
Jun 26, 2017
I have 20x4 LCD and I2C board. I followed
the steps in this Wiki. Scanner returned
0x27. The board seems similar to v3. Trying
this with UNO. The LCD is blinking 3 times
(as per setup()), then only 1st and 3rd lines
are showing up as blocks. Contrast is only
changing the block intensity; no text is
being displayed. What could be the problem
? What else I can try ?

https://arduino-info.wikispaces.com/LCD-Blue-I2C 16/17
3/12/2018 arduino-info - LCD-Blue-I2C

(https://www.wikispaces.com/user/view/vdprao) vdprao
(https://www.wikispaces.com/user/view/vdprao)
Jun 26, 2017
It's working now. I deleted old/original lib but
only restarted the IDE earlier. Now, I
disconnected and reconnected the I2C
board also. Loose connection for the data
pin, may be.

Help · About · Pricing · Privacy · Terms · Support


Contributions to https://arduino-info.wikispaces.com/ are licensed under a Creative Commons Attribution Non-Commercial 3.0 License.
Portions not contributed by visitors are Copyright 2018 Tangient LLC
TES: The largest network of teachers in the world

https://arduino-info.wikispaces.com/LCD-Blue-I2C 17/17

You might also like