PololuHD44780 library
|
Version: 2.0.0
Release date: 2016-08-17
www.pololu.com
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.
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.
If you are using version 1.6.2 or later of the Arduino software (IDE), you can use the Library Manager to install this library:
If this does not work, you can manually install the library:
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:
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.
To clear your LCD's screen, use clear
:
To print strings and numbers to it, you can use print
:
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):
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:
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.