Tutorial.LiquidCrystal History

Hide minor edits - Show changes to markup

June 06, 2010, at 11:46 AM by Equipo Traduccion -
Changed lines 15-28 from:

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.

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.

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.

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.

to:

Un pin de selección de registro (RS) que controla en qué parte de la memoria del LCD estás escribiendo datos. Puedes seleccionar bien el regisro de datos, que mantiene lo que sale en la pantalla, o un registro de instrucción, que es donde el controlador del LCD busca las instrucciones para saber cual es lo siguiente que hay que hacer.

El pin de lectura/escritura (R/W)que selecciona el modo de lectura o el de escritura.

Un pin para habilitar (enable) que habilita los registros.

8 pines de datos (D00-D07). Los estados de estos pines (nivel alto o bajo) son los bits que estás escribiendo a un registro cuando escribes, o los valores de lectura cuando estás leyendo.

Hay también un pin de contraste del display (Vo), pines de alimentación (+5V y GND) y pines de retro-iluminación (Bklt+ y Bklt-), que te permiten alimentar el LCD, controlar el contraste del display, o encender y apagar la retro-iluminación, respectivamente.

El proceso de controlar el display involucra la colocación de los datos que componen la imagen de lo que quieres mostrar, en los registros de datos, y luego, colocar las instrucciones, en el registro de instrucciones. La librería LiquidCrystal te simplifica todo este proceso de forma que no neesitas saber las instrucciones de bajo nivel.

Los LCD-s compatibles con Hitachi pueden ser controlados de dos modos: 4 bits u 8 bits. El modo de 4 bits requiere siete pines de E/S de Arduino, mientras el modo de 8 bits requiere 11 pines. Para mostrar texto en la pantalla, puedes hacer la mayoría de las cosas en modo 4 bits, por lo que el ejemplo muestra como controlar un LCD de 2x16 en modo de 4 bits.

June 06, 2010, at 11:27 AM by Equipo Traduccion -
Changed lines 1-2 from:

Examples > Libraries > LiquidCrystal

to:

Ejemplos > Librarías > LiquidCrystal

Changed lines 5-8 from:

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.

to:

La librería LiquidCrystal te permite controlar displays LCD que sean complatibles con el driver Hitachi HD44780. Hay muchos de ellos ahí fuera, y puedes comunicarte con ellos a través del interfaz de 16 pines.

Este sketch de ejemplo imprime "Hello World!" en el LCD y muestra el tiempo en segundos desde que Arduino fué reseteado por última vez.

Changed lines 11-14 from:

output of the sketch on a 2x16 LCD

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:

to:

salida del sketch en un LCD de 2x16

El LCD tiene un interfaz paralelo, significando esto que el microcontrolador tiene que manipular varios pines del interfaz a la vez para controlarlo. El interfaz consta de los siguientes pines:

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