Click here to Skip to main content
13,149,427 members (55,161 online)
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 14 Jan 2014

SerialLcd Library for Arduino

, 14 Jan 2014
Rate this:
Please Sign up or sign in to vote.
Arduino.SerialLcd library


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. Smile | <img src=


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.

Hardware Setup

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.

Fritzing designs:



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); // rx=3, tx=4
SerialLcd lcd(&ss); // serial lcd 

If you use hardware serial (Serial), you just pass the reference of it to the SerialLcd constructor.

#include <SerialLcd.h>

SerialLcd lcd(&Serial);

Let's continue with software serial.

In the setup function, you initialize the stream (in this case ss) with 9600 baud rate. Then use lcd as the output device.


Usage is straightforward. Displaying a string:

lcd.println("first line");
lcd.println("second line");

Clear screen and move cursor to position 0:


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 1.


You can send any ASCII character and there is an extension list for the printable characters. You can find this list in this document.

lcd.sendChar(0xF7); // greek pi

Moving cursor left or right:


Showing/hiding underline cursor:

lcd.showUnderlineCursor(1); // show underline cursor
lcd.showUnderlineCursor(0); // hide underline cursor 

Showing/hiding blinking cursor:

lcd.showBlinkCursor(1); // show blinking cursor
lcd.showBlinkCursor(0); // hide blinking cursor 

Scrolling screen left or right by 1 step:


Turn the display on/off:

lcd.displayOn(0); // off
lcd.displayOn(1); // on 

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.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Vedat Ozan Oner
Turkey Turkey
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionIs there a backpack? Pin
Alain Peralta31-Mar-14 18:12
memberAlain Peralta31-Mar-14 18:12 
AnswerRe: Is there a backpack? Pin
Vedat Ozan Oner1-Apr-14 0:58
professionalVedat Ozan Oner1-Apr-14 0:58 
GeneralRe: Is there a backpack? Pin
Alain Peralta1-Apr-14 13:17
memberAlain Peralta1-Apr-14 13:17 
GeneralRe: Is there a backpack? Pin
Vedat Ozan Oner1-Apr-14 20:19
professionalVedat Ozan Oner1-Apr-14 20:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170924.2 | Last Updated 14 Jan 2014
Article Copyright 2014 by Vedat Ozan Oner
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid