0% found this document useful (0 votes)
64 views7 pages

Arduino-Info - LCD-Blue-I2C

LCD Arduino

Uploaded by

jp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views7 pages

Arduino-Info - LCD-Blue-I2C

LCD Arduino

Uploaded by

jp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Inicio del wiki Cambios Recientes Pages and Files Miembros

Búsqueda
LCD-Blue-I2C Editar 0 80 …

HOME
LCD Displays (Blue and YELLOW) with I2C/TWI Interface
ABOUT US!
YourDuinoShop
ALL the displays will now use the great NEWSLETTERS
Library written by F Malpartida . You
should download that Library HERE BLOG
(Click) THIS WIKI:

NOTE! THERE ARE THREE (or More??)


WHAT IS
VERSIONS OF THE 2 and 4 LINE DISPLAYS. Check the small "backpack" interface
Arduino?
board on the back.
LEARNING
LCD Version 1 - Marked "YwRobot Arduino LCM1602 IIC V1" Arduino:
LCD Version 2 - Marked "Arduino-IIC-LCD GY-LCD-V1"
Arduino:
LCD Version 3 - Marked "LCM1602 IIC A0 A1 A2"
WhatIsIt?
Hands-On Learn
These displays are Available HERE:
Example Sketch
NOTE! These displays are very clear bright white on dark blue (or Black on Yellow)
Arduino Librarie
background: it is difficult to get a good digital photo due to polarization effects.
ARDUINO
WHY THE I2C (IIC) TYPE LCD DISPLAY? HOWTO:
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 CABLES, WIRES
of pins using a normal LCD shield. With this I2C interface LCD module, you only need 2 and PINS
lines (I2C) to display information. If you already have I2C devices in your project, this SENSOR SHIEL
LCD module actually uses no more pins at all. More information about I2C/TWI ARDUINO POW
(Wikipedia) SERVO MOTOR
This unit connects with 4 wires including Vcc and Gnd. It is easiest with a 4-wire cable WIRELESS
(supplied) that plugs into the Sensor Shield communications connector. nRF24L01
LCD DISPLAYS
But you can wire it directly yourself if needed: There are 4 pins on the display.. (see SD CARDS
photo below) Ultrasonic Senso
TemperatureSen
IR Remotes
Stepper Motors
RealTimeClock
Keyboards/Butt
Top to bottom: PWM Frequencie
GND - GND Analog Output
VCC - 5V TUTORIALS
SDA - ANALOG Pin 4
SCL - ANALOG pin 5 BJK
On most Arduino boards, SDA (data ZZ
line) is on analog input pin 4, and SCL (clock line) is on analog input pin 5. On the
Arduino Mega, SDA is digital pin 20 and SCL is 21.
NOTE: The Blue Potentiometer (Photo) adjusts Contrast. If you don't see any
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 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")

/* YourDuino.com Example Software Sketch


16 character 2 line I2C Display
Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
[email protected] */

/*-----( 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 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 )-----*/


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

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

/* YourDuino.com Example Software Sketch


20 character 4 line I2C Display
Backpack Interface labelled "YwRobot Arduino LCM1602 IIC V1"
[email protected] */

/*-----( 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 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 )-- */

/* ( 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"
[email protected] */

/*-----( 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
//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");
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)

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
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.

/* YourDuino.com Example Software Sketch


20 character 4 line I2C Display
Backpack Interface labelled "LCM1602 IIC A0 A1 A2"
[email protected] */

/*-----( 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, 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");
ces.com/)
You| Iniciar
are notSesión (http://www.wikispaces.com/site/signin?goto=http%3A%2F%2Farduino-info.wikispaces.com%2FLCD-Blue-I2C)
a member
deof
la this wiki. Join now Dismiss
y(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 )-- */

/* ( THE END ) */

Detailed information about LCD displays from Donald Weiman


([email protected])
LCD Addressing.pdf
Details Download 251 KB

Ayuda · Acerca de · Blog · Precio · Privacidad · Términos · Apoyo


Contributions to http://arduino-info.wikispaces.com/ are licensed under a Creative Commons Attribution Non-Commercial 3.0 License.
Portions not contributed by visitors are Copyright 2013 Tangient LLC

You might also like