Learning   Examples | Foundations | Hacking | Links

Examples > Libraries > LiquidCrystal

LiquidCrystal - autoscroll()

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 autoscroll() and noAutoscroll() methods to move all the text on the display left or right.

autoscroll() moves all the text one space to the left each time a letter is added

noAutoscroll() turns scrolling off

This sketch prints the characters 0 to 9 with autoscroll off, then moves the cursor to the bottom right, turns autoscroll on, and prints them again.

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

  • Hello World - displays "hello world!" and the seconds since reset
  • Blink - control of the block-style cursor
  • Cursor - control of the underscore-style cursor
  • Display - quickly blank the display without losing what's on it.
  • Text Direction - control which way text flows from the cursor
  • Autoscroll - automatically scroll new text
  • Serial input - accepts serial input, displays it
  • SetCursor - set the cursor position
  • Scroll - scroll text left and right

Circuit

  • LCD RS pin connected to digital I/O pin 12
  • LCD enable pin connected to digital I/O pin 11
  • LCD pins D4 - D7 connected to digital I/O pins 5 through 2, 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.

Note: This wiring diagram is different than the one for previous versions of the LiquidCrystal library. The R/W pin is connected to ground, and the Enable pin is moved over to pin 11, saving you one I/O pin for other uses.

click the image to enlarge

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Schematic:

click the image to enlarge

Code