skip navigational linksPJRC
Shopping Cart Checkout Shipping Cost Download Website
Home MP3 Player 8051 Tools All Projects PJRC Store Site Map
You are here: Teensy Teensyduino Libraries LiquidCrystal Search PJRC

PJRC Store
Teensy, $18
Teensy Pins, $21
Teensy++, $24
Teensy++ Pins, $27
USB Cable, $4
Teensy
Main Page
Getting Started
How-To Tips
Code Library
Projects
Teensyduino
Reference

LiquidCrystal Library

LiquidCrystal lets you use small character type displays. Characters and a limited set of custom symbols can be used.

Download: LiquidCrystal is included with Arduino software

LiquidCrystal works perfectly with Teensy and Teensy++.

Hardware Requirements

LCD PinFunction
1Ground (Vss)
2+5 Volts (Vdd)
3Contrast Adjust (Vee)
4RS
5R/W
6Enable (E)
7D0
8D1
9D2
10D3
11D4
12D5
13D6
14D7
15Backlight Power
16Backlight Power
Nearly all character type displays have a 14 pin interface. Often 2 extra pins are added for power to the backlight. Pins 1 and 2 must be connected to power. A 10K potentiometer is used for contrast adjustment, with the center pin connected to pin 3. The two outer pins of the potentiometer connect to +5 volts and ground.

The R/W pin should to be connected to ground. There is an option to "use" the R/W pin, but LiquidCrystal never actually uses it, so just connect R/W to directly to ground.

Only 6 wires are needed between the Teensy and the LCD, and you can use any pins. Just list those 6 pin numbers when you create the LiquidCrystal object.

Pins 7 to 10 (D0 to D3) are not needed. There is an option to use these for higher speed. Unlike R/W, LiquidCrystal will use these other pins if you connect them, but rarely is the small speedup worth the trouble of 4 more wires.

Basic Usage

LiquidCrystal lcd(RS, Enable, D4, D5, D6, D7)

Create the LiquidCrystal object and specify the 6 pins where the LCD is connected. The library offers ways to connect more wires, but there is little advantage to using more than 6. You can connect more than one LCD (each to its own 6 pins) and create a separate LiquidCrystal objects for each.

lcd.begin(width, height);

Initialize the display and set the size.

lcd.print(anything);

Print a number or text. This works the same as Serial.print(), but prints to the LCD.

lcd.setCursor(x, y);

Move the cursor to position (x, y). These are zero-based coordinates.

Many other functions are available. See below for links to more details.

Example Program

This example can be loaded with File > Examples > LiquidCrystal > HelloWorld.
// 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);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // 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);
}


Details

For more details, please refer to the official LiquidCrystal page.

Custom Character Creator by Druno Maia