Using an LCD is one of the ways to output information in Arduino projects. The main drawback about an LCD is that it occupies too many pins on your Arduino board. But there are some serial implementations such as here. So I got one.
If you visit the LiquidCrystal reference page on the Arduino website, you will see that it is based on Hitachi HD44780 (or a compatible) chipset. An LCD needs many pins like data, clock, select, contrast adjustment, etc. which consumes your Arduino resources. However, a serial LCD eliminates the necessity for so many pins. Actually, it uses another microprocessor which drives the LCD. You command this microprocessor from your Arduino board over a stream and it handles the rest for you.
Serial LCD has three lines which are GND, Vcc, and Rx. All you need is to connect the Rx (receive) line of the serial LCD to the Tx (transmit) line of the stream on Arduino board. This stream can be either hardware serial or software serial. It is up to you which type of communication to use.
If you decide to use hardware serial, you will use the digital pin1 of your Arduino board as serial transmit. Pin0 is the receive pin of
Serial and Pin1 is for transmit. But in that case, I advice you to disconnect Arduino board from your computer, because
Serial is used as shared resource for the serial communication between the computer and the board.
If you will use software serial, the only thing is to decide which digital pin to use as serial transmit.
One more thing; it is better to use an external power source for your Arduino board because an LCD drains more power than that computer's USB port can provide, or you take the risk of damaging your Arduino board.
Be aware that you may need to do some soldering if you decide to buy a serial LCD like mine. There is another PCB at the back of the LCD soldered to the LCD's pins.
Click to enlarge images.
Sorry for the connections of the LCDs on above images. I couldn't find a serial LCD part in the Fritzing editor, so I have used normal LCDs. Actually, there exist a 3-pin connector on the side of the serial LCD.
Using the Code
You can communicate with this model of serial LCD as here. As you see, commands are one-byte values with some parameters. What I did in this library is to convert them into more meaningful functions.
Assuming that you have placed the library files in the libraries folder of your Arduino IDE, you can include the header file in your sketch. If you will use
SoftwareSerial as your communication infrastructure, you have to include its header, too. You can download SoftwareSerial library from the official Arduino website.
#include <SoftwareSerial.h> // SoftwareSerial header
#include <SerialLcd.h> // SerialLcd header
SoftwareSerial ss(3,4); SerialLcd lcd(&ss);
If you use hardware serial (
Serial), you just pass the reference of it to the
Let's continue with software serial.
In the setup function, you initialize the stream (in this case
) with 9600 baud rate. Then use
as the output device.
Usage is straightforward. Displaying a
Clear screen and move cursor to position
Moving cursor to a specific location needs some explanation. If your LCD is 16x2 type, then moving cursor to location 20 places cursor on the 5th column of the second row. Position index starts from
You can send any ASCII character and there is an extension list for the printable characters. You can find this list in this document.
Moving cursor left or right:
Showing/hiding underline cursor:
Showing/hiding blinking cursor:
Scrolling screen left or right by 1 step:
Turn the display on/off:
Points of Interest
My library implementation depends on a specific product, but most of them are very similar to this one. When you buy another, you can use this library with a small or no change. Commands are defined in the header file. All you have to do is to compare these commands with yours.