PololuHD44780 library
 All Classes Files Functions
PololuHD44780 library Documentation

Version: 1.0.0
Release date: 2014 Dec 11
www.pololu.com

Summary

This is a C++ library for the Arduino IDE that allows you to control an LCD that uses the Hitachi HD44780 protocol. This library is very similar to the LiquidCrystal library, but it provides more separation between the low-level hardware access functions and the high-level functions so that the low-level functions can be replaced if necessary.

This library assumes that you have the RS, E, DB4, DB5. DB6, and DB7 pins of the LCD connected to your microcontroller, and that the RW pin is pulled low. With this configuration, it is not possible to poll the LCD's busy flag, so blocking delays are used after each command in order to give it time to complete.

Supported platforms

This library was designed to be used with the Arduino IDE versions 1.0.x or 1.5.x and will probably not work with earlier versions.

This library should work with any board that can be programmed by those versions of the Arduino IDE.

Getting Started

Download the pololu-hd44780-arduino library from GitHub, decompress it, and drag the "PololuHD44780" folder into the "libraries" subdirectory inside your Arduino sketchbook directory. You can view your sketchbook location by selecting File->Preferences in the Arduino environment. If there is not already a "libraries" folder in that location, you should create it yourself. After installing the library, restart the Arduino environment. Example code for using this library can be found in the File->Examples menu.

Creating a PololuHD44780 object

Unless you are using a library that creates an LCD object for you in some way, you will want to create a PololuHD44780 object that can be used to access your LCD. To do so, add these lines near the top of your sketch:

#include <PololuHD44780.h>
PololuHD44780 lcd(7, 6, 5, 4, 3, 2);

The numbers listed above are the pin numbers for the pins that are controlling the LCD. The pins are specified in this order: RS, E, DB4, DB5, DB6, DB7.

Basic usage

To clear your LCD's screen, use clear:

lcd.clear();

To print strings and numbers to it, you can use print:

lcd.print("hi");
lcd.print(13);
lcd.print(14, HEX);

The print function is provided by Arduino's Print class, so it behaves just like the print function on the Serial object and can print a lot of different things. See the Arduino print() documentation for more information, or look at the overloads of print that are defined in Print.h in the Arduino IDE source code.

To control where data is printed on the LCD, you can use gotoXY(). The following code positions the cursor on the first column (column 0) of the second line (line 1):

lcd.gotoXY(0, 1)

If you call these functions too often in a tight loop, your LCD might flicker and be hard to read. Here is some code that waits at least 100 milliseconds between writes to the LCD:

void loop()
{
static uint16_t lastDisplayTime;
if ((uint16_t)(millis() - lastDisplayTime) >= 100)
{
lcd.clear();
lcd.print("hi");
lastDisplayTime = millis();
}
}

Documentation

For complete documentation of this library, including many features that were not covered here, see the PololuHD44780.h file documentation from https://pololu.github.io/pololu-hd44780-arduino.

Version history