Tutorial.LiquidCrystal History

Hide minor edits - Show changes to markup

April 09, 2013, at 06:01 PM by Federico -
Changed line 42 from:

Before wiring the LCD screen to your Arduino we suggest you to solder a pin headers strip to the LCD screen, as you can see in the image above.

to:

Before wiring the LCD screen to your Arduino we suggest to solder a pin header strip to the 14 (or 16) pin count connector of the LCD screen, as you can see in the image above.\\

April 09, 2013, at 05:52 PM by Federico -
Added line 33:
  • pin headers to solder to the LCD display pins
Added line 42:

Before wiring the LCD screen to your Arduino we suggest you to solder a pin headers strip to the LCD screen, as you can see in the image above.

December 10, 2012, at 04:12 PM by Scott Fitzgerald -
Changed line 41 from:

To wire your LED screen to your Arduino, connect the following pins:

to:

To wire your LCD screen to your Arduino, connect the following pins:

November 16, 2011, at 04:36 AM by Scott Fitzgerald -
Changed lines 64-65 from:
to:
September 23, 2010, at 10:47 PM by Christian Cerrito -
Changed lines 3-4 from:

LiquidCrystal

to:

LiquidCrystal - "Hello World!"

September 23, 2010, at 10:47 PM by Christian Cerrito -
Changed lines 3-4 from:

LiquidCrystal

to:

LiquidCrystal

September 21, 2010, at 10:42 PM by Christian Cerrito -
Changed line 69 from:

<<<<<<<

to:
Changed lines 73-74 from:
  • [[Reference/LiquidCrystal | Liquid Crystal Library]
to:
September 21, 2010, at 10:42 PM by Christian Cerrito -
Added line 69:

<<<<<<<

Changed lines 73-74 from:
to:
  • [[Reference/LiquidCrystal | Liquid Crystal Library]
September 21, 2010, at 10:41 PM by Christian Cerrito -
Changed lines 25-26 from:

The process of controlling the display involves putting the data that form the image of what you want to display into the data registers, then putting instructions in the instruction register. The LiquidCrystal library simplifies this for you so you don't need to know the low-level instructions.

to:

The process of controlling the display involves putting the data that form the image of what you want to display into the data registers, then putting instructions in the instruction register. The LiquidCrystal Library simplifies this for you so you don't need to know the low-level instructions.

Changed lines 69-72 from:
to:
September 21, 2010, at 10:30 PM by Christian Cerrito -
Changed lines 25-26 from:

The process of controlling the display involves putting the data that form the image of what you want to display into the data registers, then putting instructions in the instruction register. The LiquidCrystal library simplifies this for you so you don't need to know the low-level instructions.

to:

The process of controlling the display involves putting the data that form the image of what you want to display into the data registers, then putting instructions in the instruction register. The LiquidCrystal library simplifies this for you so you don't need to know the low-level instructions.

September 21, 2010, at 12:46 PM by Tom Igoe -
Changed lines 64-65 from:
to:
source http://arduino.cc/en/pub/code/master/libraries/LiquidCrystal/examples/HelloWorld/HelloWorld.pde lang=arduino tabwidth=4
)
September 21, 2010, at 12:45 PM by Tom Igoe -
Changed lines 64-65 from:
to:
September 21, 2010, at 08:53 AM by Christian Cerrito -
Added lines 41-51:

To wire your LED screen to your Arduino, connect the following pins:

  • LCD RS pin to digital pin 12
  • LCD Enable pin to digital pin 11
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2

Additionally, wire a 10K pot to +5V and GND, with it's wiper (output) to LCD screens VO pin (pin3).

September 21, 2010, at 08:47 AM by Christian Cerrito -
Changed lines 41-43 from:

click the image to enlarge

to:

click the images to enlarge

Changed lines 46-47 from:
to:
September 21, 2010, at 08:46 AM by Christian Cerrito -
Changed lines 43-45 from:

There is no circuit for this example.

to:
Added lines 46-47:
September 21, 2010, at 08:44 AM by Christian Cerrito -
Changed line 40 from:
div class=circuit
)
to:
Added line 42:
September 21, 2010, at 08:44 AM by Christian Cerrito -
Added lines 32-36:
  • LCD Screen (compatible with Hitachi HD44780 driver)
  • 10k Potentiometer
  • breadboard
  • hook-up wire
Changed lines 40-41 from:
to:
div class=circuit
)

click the image to enlarge

September 21, 2010, at 08:19 AM by Christian Cerrito -
Changed lines 29-34 from:
to:
Added lines 34-49:
September 21, 2010, at 08:18 AM by Christian Cerrito -
Added line 32:
Added line 34:
September 21, 2010, at 08:17 AM by Christian Cerrito -
Changed lines 29-30 from:
to:

Code

Deleted line 32:
September 21, 2010, at 08:09 AM by Christian Cerrito -
Changed lines 33-44 from:
to:
April 22, 2010, at 09:40 PM by Tom Igoe -
February 09, 2010, at 12:12 AM by Tom Igoe -
Changed lines 31-98 from:
 /*
   LiquidCrystal Library - setCursor
  
  Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
  library works with all LCD displays that are compatible with the 
  Hitachi HD44780 driver. There are many of them out there, and you
  can usually tell them by the 16-pin interface.
  
  This sketch prints to all the positions of the LCD using the
  setCursor(0 method:
  
  The circuit:
  * LCD RS pin to digital pin 12
  * LCD Enable pin to digital pin 11
  * LCD D4 pin to digital pin 5
  * LCD D5 pin to digital pin 4
  * LCD D6 pin to digital pin 3
  * LCD D7 pin to digital pin 2
  * 10K resistor:
  * ends to +5V and ground
  * wiper to LCD VO pin (pin 3)
  
  Library originally added 18 Apr 2008
  by David A. Mellis
  library modified 5 Jul 2009
  by Limor Fried (http://www.ladyada.net)
  example added 9 Jul 2009
  by Tom Igoe 
  modified 22 August 2009
  by Tom Igoe
  
  http://www.arduino.cc/en/Tutorial/LiquidCrystal
  */

 // include the library code:
 #include <LiquidCrystal.h>

 // these constants won't change.  But you can change the size of
 // your LCD using them:
 const int numRows = 2;
 const int numCols = 16;

 // initialize the library with the numbers of the interface pins
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

 void setup() {
   // set up the LCD's number of rows and columns: 
   lcd.begin(numRows, numCols);
 }

 void loop() {
   // loop from ASCII 'a' to ASCII 'z':
   for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) {
     // loop over the rows:
     for (int thisRow= 0; thisRow < numRows; thisRow++) {
       // loop over the columns:
       for (int thisCol = 0; thisCol < numCols; thisCol++) {
         // set the cursor position:
         lcd.setCursor(thisCol,thisRow);
         // print the letter:
         lcd.print(thisLetter, BYTE);
         delay(200);
       }
     }
   }
 }
to:
August 22, 2009, at 04:24 PM by Tom Igoe -
Deleted line 29:
Changed line 33 from:
   LiquidCrystal Library - Hello World
to:
   LiquidCrystal Library - setCursor
Changed lines 40-41 from:
  This sketch prints "Hello World!" to the LCD
  and shows the time.
to:
  This sketch prints to all the positions of the LCD using the
  setCursor(0 method:
Changed line 43 from:
   The circuit:
to:
  The circuit:
Added lines 59-60:
  by Tom Igoe 
  modified 22 August 2009
Deleted lines 61-62:
  modified 25 July 2009
  by David A. Mellis
Deleted line 62:
  
Added lines 69-73:
 // these constants won't change.  But you can change the size of
 // your LCD using them:
 const int numRows = 2;
 const int numCols = 16;
Changed lines 79-81 from:
   lcd.begin(16, 2);
   // Print a message to the LCD.
   lcd.print("hello, world!");
to:
   lcd.begin(numRows, numCols);
Changed lines 83-87 from:
   // set the cursor to column 0, line 1
   // (note: line 1 is the second row, since counting begins with 0):
   lcd.setCursor(0, 1);
   // print the number of seconds since reset:
   lcd.print(millis()/1000);
to:
   // loop from ASCII 'a' to ASCII 'z':
   for (int thisLetter = 'a'; thisLetter <= 'z'; thisLetter++) {
     // loop over the rows:
     for (int thisRow= 0; thisRow < numRows; thisRow++) {
       // loop over the columns:
       for (int thisCol = 0; thisCol < numCols; thisCol++) {
         // set the cursor position:
         lcd.setCursor(thisCol,thisRow);
         // print the letter:
         lcd.print(thisLetter, BYTE);
         delay(200);
       }
     }
   }
Deleted line 98:
August 05, 2009, at 04:50 PM by Tom Igoe -
Deleted lines 30-31:

Code

Changed line 34 from:
   LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight()
to:
   LiquidCrystal Library - Hello World
Changed lines 41-43 from:
  This sketch prints "Hello World!" to the LCD and uses the
  scrollDisplayLeft() and scrollDisplayRight() methods to scroll
  the text.
to:
  This sketch prints "Hello World!" to the LCD
  and shows the time.
Changed lines 60-62 from:
  by Tom Igoe 
to:
  by Tom Igoe
  modified 25 July 2009
  by David A. Mellis
Added line 64:
  
Changed line 69 from:
 #include <LiquidCrystal.h>
to:
 #include <LiquidCrystal.h>
Changed line 72 from:
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
to:
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Changed lines 76-77 from:
   lcd.begin(2, 16);
   lcd.setCursor(0,7);
to:
   lcd.begin(16, 2);
Changed lines 82-88 from:
   // scroll 27 positions (display length + string length) to the left:
   for (int positionCounter = 0; positionCounter < 27; positionCounter++) {
     // scroll one position left:
     lcd.scrollDisplayLeft(); 
     // wait a bit:
     delay(200);
   }
to:
   // set the cursor to column 0, line 1
   // (note: line 1 is the second row, since counting begins with 0):
   lcd.setCursor(0, 1);
   // print the number of seconds since reset:
   lcd.print(millis()/1000);
 }
Deleted lines 88-95:
   // scroll 27 positions (display length + string length) to the right:
   for (int positionCounter = 0; positionCounter < 27; positionCounter++) {
     // scroll one position right:
     lcd.scrollDisplayRight(); 
     // wait a bit:
     delay(200);
   }
 }
July 09, 2009, at 10:12 PM by Tom Igoe -
Changed lines 25-26 from:

The process of controlling the display involves putting the bitmap of what you want to display into the data registers,then putting instructions in the instruction register. The LiquidCrystal simplifies this for you so you don't need to know the low-level instructions.

to:

The process of controlling the display involves putting the data that form the image of what you want to display into the data registers, then putting instructions in the instruction register. The LiquidCrystal library simplifies this for you so you don't need to know the low-level instructions.

July 09, 2009, at 09:52 PM by Tom Igoe -
Deleted line 32:
Changed line 36 from:
   LiquidCrystal Library - Hello World
to:
   LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight()
Changed lines 43-44 from:
  This sketch prints "Hello World!" to the LCD
  and shows the time.
to:
  This sketch prints "Hello World!" to the LCD and uses the
  scrollDisplayLeft() and scrollDisplayRight() methods to scroll
  the text.
Changed line 47 from:
  The circuit:
to:
   The circuit:
Changed lines 49-50 from:
  * LCD R/W pin to digital pin 11
  * LCD Enable pin to digital pin 10
to:
  * LCD Enable pin to digital pin 11
Changed lines 61-62 from:
  by Limor Fried
  example added 7 Jul 2009
to:
  by Limor Fried (http://www.ladyada.net)
  example added 9 Jul 2009
Changed line 72 from:
 LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
to:
 LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Changed line 75 from:
   // set up the LCD's number of columns and rows: 
to:
   // set up the LCD's number of rows and columns: 
Added line 77:
   lcd.setCursor(0,7);
Changed lines 83-87 from:
   // set the cursor to column 0, line 1:
   lcd.setCursor(0, 1);
   // print the number of seconds since reset:
   lcd.print(millis()/1000);
 }
to:
   // scroll 27 positions (display length + string length) to the left:
   for (int positionCounter = 0; positionCounter < 27; positionCounter++) {
     // scroll one position left:
     lcd.scrollDisplayLeft(); 
     // wait a bit:
     delay(200);
   }
Added lines 91-98:
   // scroll 27 positions (display length + string length) to the right:
   for (int positionCounter = 0; positionCounter < 27; positionCounter++) {
     // scroll one position right:
     lcd.scrollDisplayRight(); 
     // wait a bit:
     delay(200);
   }
 }
July 08, 2009, at 08:03 PM by Tom Igoe -
July 08, 2009, at 08:03 PM by Tom Igoe -
Changed lines 29-65 from:

NOTE: The LiquidCrystal library has undergone revisions after Arduino version 0016. Thanks to Limor Fried for the rewrite to include 4-bit and 8-bit modes and more functionality. If you are running Arduino 0016 or earlier, please download the current version of the LiquidCrystal library and install it in your hardware/libraries folder.

Users of 0017 and later will not need to install the update.

Other LiquidCrystal Library Examples

  • HelloWorld - displays "hello world!" and the seconds since reset
  • Blink
  • Cursor
  • Display
  • IncrementDecrement
  • Scroll
  • Serial input - accepts serial input, displays it
  • SetCursor
  • Shift

Circuit

  • LCD RS pin connected to digital I/O pin 12
  • LCD R/W pin connected to digital I/O pin 11
  • LCD enable pin connected to digital I/O pin 10
  • LCD pins D0 - D3 connected to digital I/O pins 2 through 5, respectively
  • LCD voltage and ground connected to +5V and ground
  • LCD Vo pin, which controls the contrast, connected to a potentiometer. Adjust the potentiometer to get the text to display at the contrast ratio you want.

click the image to enlarge

Schematic:

click the image to enlarge

to:
July 08, 2009, at 08:01 PM by Tom Igoe -
Deleted lines 34-35:

Other LiquidCrystal Library Examples

July 08, 2009, at 07:57 PM by Tom Igoe -
Changed line 51 from:
  • LCD enavle pin connected to digital I/O pin 10
to:
  • LCD enable pin connected to digital I/O pin 10
July 08, 2009, at 06:50 PM by Tom Igoe -
Changed lines 35-37 from:
  • HelloWorld
to:

Other LiquidCrystal Library Examples

  • HelloWorld - displays "hello world!" and the seconds since reset
Changed line 43 from:
to:
July 08, 2009, at 06:47 PM by Tom Igoe -
Added lines 33-44:

Other LiquidCrystal Library Examples

  • HelloWorld
  • Blink
  • Cursor
  • Display
  • IncrementDecrement
  • Scroll
  • LiquidCrystalSerial - accepts serial input, displays it
  • SetCursor
  • Shift
July 08, 2009, at 06:39 PM by Tom Igoe -
Added lines 23-24:

There's also a display constrast pin (Vo), power supply pins (+5V and Gnd) and LED Backlight (Bklt+ and BKlt-) pins that you can use to power the LCD, control the display contrast, and turn on and off the LED backlight, respectively.

July 08, 2009, at 06:34 PM by Tom Igoe -
Added lines 13-24:

The LCDs have a parallel interface, meaning that the microcontroller has to manipulate several interface pins at once to control the display. The interface consists of the following pins:

A register select (RS) pin that controls where in the LCD's memory you're writing data to. You can select either the data register, which holds what goes on the screen, or an instruction register, which is where the LCD's controller looks for instructions on what to do next.

A Read/Write (R/W) pin that selects reading mode or writing mode

An Enable pin that enables writing to the registers

8 data pins (D0 -D7). The states of these pins (high or low) are the bits that you're writing to a register when you write, or the values you're reading when you read.

The process of controlling the display involves putting the bitmap of what you want to display into the data registers,then putting instructions in the instruction register. The LiquidCrystal simplifies this for you so you don't need to know the low-level instructions.

July 08, 2009, at 06:19 PM by Tom Igoe -
Changed lines 15-16 from:

NOTE: The LiquidCrystal library has undergone revisions after Arduino version 0016. Thanks to Limor Fried for the rewrite to include 4-bit and 8-bit modes and more functionality. If you are running Arduino 0016 or earlier, please download the current version of the LiquidCrystal library? and install it in your hardware/libraries folder.

to:

NOTE: The LiquidCrystal library has undergone revisions after Arduino version 0016. Thanks to Limor Fried for the rewrite to include 4-bit and 8-bit modes and more functionality. If you are running Arduino 0016 or earlier, please download the current version of the LiquidCrystal library and install it in your hardware/libraries folder.

July 08, 2009, at 06:16 PM by Tom Igoe -
Added line 10:
July 08, 2009, at 06:16 PM by Tom Igoe -
Added lines 9-11:

output of the sketch on a 2x16 LCD

July 08, 2009, at 06:05 PM by Tom Igoe -
Changed lines 11-12 from:

NOTE: The LiquidCrystal library has undergone revisions after Arduino version 0016. If you are running Arduino 0016 or earlier, please download the current version of the LiquidCrystal library? and install it in your hardware/libraries folder.

to:

NOTE: The LiquidCrystal library has undergone revisions after Arduino version 0016. Thanks to Limor Fried for the rewrite to include 4-bit and 8-bit modes and more functionality. If you are running Arduino 0016 or earlier, please download the current version of the LiquidCrystal library? and install it in your hardware/libraries folder.

July 08, 2009, at 05:55 PM by Tom Igoe -
Added lines 11-14:

NOTE: The LiquidCrystal library has undergone revisions after Arduino version 0016. If you are running Arduino 0016 or earlier, please download the current version of the LiquidCrystal library? and install it in your hardware/libraries folder.

Users of 0017 and later will not need to install the update.

Added lines 37-94:
July 08, 2009, at 05:51 PM by Tom Igoe -
Added lines 1-32:

Examples > Libraries > LiquidCrystal

LiquidCrystal

The LiquidCrystal library allows you to control LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface.

This example sketch prints "Hello World!" to the LCD and shows the time in seconds since the Arduino was reset.

The Hitachi-compatible LCDs can be controlled in two modes: 4-bit or 8-bit. The 4-bit mode requires seven I/O pins from the Arduino, while the 8-bit mode requires 11 pins. For displaying text on the screen, you can do most everything in 4-bit mode, so example shows how to control a 2x16 LCD in 4-bit mode.

Circuit

  • LCD RS pin connected to digital I/O pin 12
  • LCD R/W pin connected to digital I/O pin 11
  • LCD enavle pin connected to digital I/O pin 10
  • LCD pins D0 - D3 connected to digital I/O pins 2 through 5, respectively
  • LCD voltage and ground connected to +5V and ground
  • LCD Vo pin, which controls the contrast, connected to a potentiometer. Adjust the potentiometer to get the text to display at the contrast ratio you want.

click the image to enlarge

Schematic:

click the image to enlarge

Code

Share