Hide minor edits - Show changes to markup
Examples > Libraries > 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 shows how to use the scrollDisplayLeft() and scrollDisplayRight() methods to reverse the direction the text is flowing. It prints "Hello World!", scrolls it offscreen to the left, then offscreen to the right, then back to home.
Ejemplos > Librarías > LiquidCrystal
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 muestra como usar los métodos scrollDisplayLeft() y scrollDisplayRight() para invertir la dirección de flujo del texto. Imprime "Hello World!", lo muestra hacia la izquierda y después hacia la derecha, y al final vuelve al lugar de origen.
/* LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight() 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 "Hello World!" to the LCD and uses the scrollDisplayLeft() and scrollDisplayRight() methods to scroll the text. 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 25 July 2009 by David A. Mellis http://www.arduino.cc/en/Tutorial/LiquidCrystal */
// include the library code: #include <LiquidCrystal.h>
// 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(16, 2); //lcd.setCursor(0,7); // Print a message to the LCD. lcd.print("hello, world!"); delay(1000); }
void loop() { // scroll 13 positions (string length) to the left // to move it offscreen left: for (int positionCounter = 0; positionCounter < 13; positionCounter++) { // scroll one position left: lcd.scrollDisplayLeft(); // wait a bit: delay(150); }
// scroll 29 positions (string length + display length) to the right // to move it offscreen right: for (int positionCounter = 0; positionCounter < 29; positionCounter++) { // scroll one position right: lcd.scrollDisplayRight(); // wait a bit: delay(150); }
// scroll 16 positions (display length + string length) to the left // to move it back to center: for (int positionCounter = 0; positionCounter < 16; positionCounter++) { // scroll one position left: lcd.scrollDisplayLeft(); // wait a bit: delay(150); }
// delay at the end of the full loop: delay(1000);
}
(:includeurl http://arduino.googlecode.com/svn/trunk/libraries/LiquidCrystal/examples/Scroll/Scroll.pde border=0:)
This example sketch shows how to use the shiftLeft(0 and shiftRight() methods to reverse the direction the text is flowing. It starts writing letters left to right from a to m, then reverses direction until s, then reverses again until z.
This example sketch shows how to use the scrollDisplayLeft() and scrollDisplayRight() methods to reverse the direction the text is flowing. It prints "Hello World!", scrolls it offscreen to the left, then offscreen to the right, then back to home.
/* LiquidCrystal Library - Shift
/* LiquidCrystal Library - scrollDisplayLeft() and scrollDisplayRight()
This sketch demonstrates how to use shiftLeft() and shiftRight() to move the cursor.
This sketch prints "Hello World!" to the LCD and uses the scrollDisplayLeft() and scrollDisplayRight() methods to scroll the text.
The circuit:
The circuit:
modified 25 July 2009 by David A. Mellis
#include <LiquidCrystal.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int thisChar = 'a';
lcd.begin(2, 16); // turn on the cursor: lcd.cursor(); Serial.begin(9600);
lcd.begin(16, 2); //lcd.setCursor(0,7); // Print a message to the LCD. lcd.print("hello, world!"); delay(1000);
// reverse directions at 'm': if (thisChar == 'm') { // go right for the next letter lcd.shiftRight();
// scroll 13 positions (string length) to the left // to move it offscreen left: for (int positionCounter = 0; positionCounter < 13; positionCounter++) { // scroll one position left: lcd.scrollDisplayLeft(); // wait a bit: delay(150);
// reverse again at 's': if (thisChar == 's') { // go left for the next letter lcd.shiftLeft();
// scroll 29 positions (string length + display length) to the right // to move it offscreen right: for (int positionCounter = 0; positionCounter < 29; positionCounter++) { // scroll one position right: lcd.scrollDisplayRight(); // wait a bit: delay(150);
// reset at 'z': if (thisChar > 'z') { // go to (0,0): lcd.home(); // start again at 0 thisChar = 'a';
// scroll 16 positions (display length + string length) to the left // to move it back to center: for (int positionCounter = 0; positionCounter < 16; positionCounter++) { // scroll one position left: lcd.scrollDisplayLeft(); // wait a bit: delay(150);
// print the character lcd.print(thisChar, BYTE); // wait a second:
// delay at the end of the full loop:
// increment the letter:
thisChar++;
/*
/*
* LCD R/W pin to digital pin 11 * LCD Enable pin to digital pin 10
* LCD Enable pin to digital pin 11
by Limor Fried example added 7 Jul 2009
by Limor Fried (http://www.ladyada.net) example added 9 Jul 2009
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// set up the LCD's number of columns and rows:
// set up the LCD's number of rows and columns:
Examples > Libraries > 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 shows how to use the shiftLeft(0 and shiftRight() methods to reverse the direction the text is flowing. It starts writing letters left to right from a to m, then reverses direction until s, then reverses again until z.
(:include LiquidCrystalCircuit :)
*/
*/
int thisChar = 'a';
// turn on the cursor: lcd.cursor(); Serial.begin(9600);
// loop from ASCII 'a' to ASCII 'p' (16 letters): for (int thisLetter = 'a'; thisLetter < 'p'; thisLetter++) { // shift the cursor one position left:
// reverse directions at 'm': if (thisChar == 'm') { // go right for the next letter lcd.shiftRight(); } // reverse again at 's': if (thisChar == 's') { // go left for the next letter
// print the letter: lcd.print(thisLetter, BYTE); // delay a bit: delay(200);
// reset at 'z': if (thisChar > 'z') { // go to (0,0): lcd.home(); // start again at 0 thisChar = 'a'; } // print the character lcd.print(thisChar, BYTE); // wait a second: delay(1000); // increment the letter: thisChar++; }
// loop from ASCII 'a' to ASCII 'p' (16 letters): for (int thisLetter = 'a'; thisLetter < 'p'; thisLetter++) { // shift the cursor one position right: lcd.shiftRight(); // print the letter: lcd.print(thisLetter, BYTE); // delay a bit: delay(200); } }
(:div class=code :)
/* LiquidCrystal Library - Shift 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 demonstrates how to use shiftLeft() and shiftRight() to move the cursor. The circuit: * LCD RS pin to digital pin 12 * LCD R/W pin to digital pin 11 * LCD Enable pin to digital pin 10 * 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 example added 7 Jul 2009 by Tom Igoe http://www.arduino.cc/en/Tutorial/LiquidCrystal
*/
// include the library code: #include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
void setup() { // set up the LCD's number of columns and rows: lcd.begin(2, 16); }
void loop() {
// loop from ASCII 'a' to ASCII 'p' (16 letters): for (int thisLetter = 'a'; thisLetter < 'p'; thisLetter++) { // shift the cursor one position left: lcd.shiftLeft(); // print the letter: lcd.print(thisLetter, BYTE); // delay a bit: delay(200); }
// loop from ASCII 'a' to ASCII 'p' (16 letters): for (int thisLetter = 'a'; thisLetter < 'p'; thisLetter++) { // shift the cursor one position right: lcd.shiftRight(); // print the letter: lcd.print(thisLetter, BYTE); // delay a bit: delay(200); } }
(:divend:)