Arduino LCD Display
In this Arduino LCD tutorial, I will take you through the steps to connecting a simple 16×2 LCD up to the Arduino.

There is a ton that you’re able to do with an LCD (liquid crystal display) so it’s a good little device to learn how to connect and communicate with.


You will find that most LCD boards are not assembled with header pins so these will need to be soldered on. If you have header pins then this isn’t too much of a task. You can probably skip soldering but getting a good connection to the board will be difficult.

The potentiometer you find in the circuit is used to control the brightness of the screen. If you find nothing is displaying or it doesn’t look right, then try turning this up or down.

If you want to see how it is all done, then be sure to check out the video below. It goes through all the steps to making sure you hook up the LCD correctly.

Equipment

The equipment that I used in this tutorial is listed below.

Arduino Uno

16×2 LCD Board

16x Header pins if LCD display has no pins

Breadboard

Breadboard wire

10k ohm Potentiometer

Arduino LCD Circuit

The circuit for the Arduino liquid crystal display is actually surprisingly easy. You will find that the most off-putting thing about it is how many wires there are that needs to be hooked up.

It’s important to note that you’re likely going to need to solder header pins onto the LCD display. This is a pretty straight forward process.

  1. Place the header pins so the short side sticks up through the holes on the display.
  2. Now solder the pins one by one ensuring you don’t accidentally connect two up. If you do connect two up then melt the solder and suck it up using a solder sucker.
  3. Once done it’s ready for use.

LCD-Display-Solder
Below are the steps that you will need to follow for hooking up the display. You can find the full circuit diagram right underneath the steps if you rather follow that.

  1. First hook the 5V pin from the Arduino to the positive line on the breadboard.
  2. Hook the ground pin to the ground rail on the breadboard.
  3. Connect the potentiometer to the breadboard and wire the positive pin the positive rail. Also wire the ground pin to the ground rail.
  4. Place the following wires to the LCD screen with pin 1 being the closest to the edge of the board.
    • Ground rail to pin 1, pin 5 & pin 16 of the LCD.
    • Positive 5v rail to pin 2 & pin 15 of the LCD.
    • Middle wire on the potentiometer to pin 3 of the LCD.
    • Wire The following Arduino Digital pins to the LCD pins.
      • Arduino to the LCD
      • Pin 12 to Pin 4
      • Pin 11 to pin 6
      • Pin 5 to pin 11
      • Pin 4 to pin 12
      • Pin 3 to pin 13
      • Pin 2 to pin 14

That’s all you need to do. If you come across any issues, please refer to the diagram below.
Arduino LCD Display Circuit Diagram

Code to Communicate with the Display

The code for communicating with the display is actually pretty straight forward. You may have thought whilst connecting it up the code would be complicated but gladly it’s not thanks to a helpful library by Limor Fried that’s already included in Arduinos main library collection.

It’s important to know that there is are already some code examples within the Arduino software. To find them simply go to File->Examples->LiquidCrystal

In here you will see a range of different examples with each showing you how to use certain methods of the liquid crystal library. To begin I suggest taking a look at the hello world example. The code for this example is below.


// include the library code:
#include 

//initialise 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 columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}

Setting up the LCD

In the code you will need to setup a variable of type LiquidCrystal. As you can see below.

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

The numbers that are passed as parameters represent the pin number on the Arduino we have connected to the relevant pin on the display. Below is an example of the function again but instead it contains the corresponding pins on the LCD.

LiquidCrystal(rs, enable, d4, d5, d6, d7)

The datasheet for your LCD board will contain the pin number and their type. For example, below is the datasheet for my board. (DB4 = D4, E = enable and so on)

LCD Datasheet Part

The above function can be extended to read from 8 data lines in total.

LiquidCrystal(rs, enable, d0, d1, d2, d3, d4, d5, d6, d7)

lcd.begin located in the setup function in the code above is used to initialize the interface to the LCD. Here is where you need to specify how many columns and rows there are on the display. For example, my display has 16 columns and 2 rows. This means we need to set it up with 16 as the first parameter and 2 as the 2nd parameter lcd.begin(cols, rows)

The Basic Methods of the LCD

If you ever need to clear the display then simply call the method lcd.clear(); This will wipe the display so that you can display a new value on there.

Make sure you have a delay beforehand so you’re able to see whatever is being displayed on the screen.

If you ever just want to move the cursor back to home rather than clearing the display then lcd.home(); will move the cursor to position 1.

If you want to print a string on the LCD display then the print method is what you need. Just simply call it like this lcd.print("My String");

The last basic method I will mention is write. This method is used to write a character to the screen. Very much like print simply call it like this: lcd.write('I');

Extra Functions

Below are almost all of the current methods that you’re able to call for the Arduino LCD display. If you want more information, then you can find the full documentation over at Arduino’s official website

  • Auto scroll: Shift text right and left.
    • autoscroll(); This will move the text one space to the left whenever a new character is added.
    • noAutoscroll(); Turns off auto scrolling
  • Cursor: This allows you turn off and on the underscore cursor.
    • noCursor(); Turns off the underscore cursor
    • Cursor(); Turns on the underscore cursor.
  • Blink: Turns on and off the blinking of the block cursor.
    • noBlink(); Turns off the blinking cursor.
    • blink(); Turns on the blinking cursor.
  • Display: Make the display go blank without losing the current text.
    • noDisplay(); Turns off the display.
    • display(); Turns on the display
  • Scroll: Allows you to scroll the text both left and right.
    • scrollDisplayLeft(); Will scroll one position to the left.
    • scrollDisplayRight(); Will scroll one position to the right.
  • Serial Display: You can setup the board to accept serial input from something like the serial monitor. You can print the text sent through the serial port on the screen.
    • write(Serial.read());
  • Set Cursor: Sets the cursor to a specific position. (Location, Line)
    • setCursor(0, 0); Will set the cursor to be at the top left.
    • setCursor(15, 1); Will set the cursor to be at the bottom right.
  • Text Direction: Allows you to tell which way the text should flow from the cursor.
    • rightToLeft(); Forces the text to flow from the left of the cursor.
    • leftToRight(); Forces the text to flow from the right of the cursor.

I have put together a script to show you an example of each of the above methods in order. You will find that the set cursor and serial display options are left out for now.  If you want to run it and give it a go then you can find it for download over at my GitHub LCD display project page.

Below is an example of the script in action!

Further Work

There is a ton of things that you’re able to do with an LCD screen. I will touch on just a few ideas that I am thinking of covering in the future below. If you have any of your own ideas, then be sure to share them by leaving a comment at the bottom of this page.

You could bundle this with a temperature sensor and have a digital temperature display for your fish tank, fridge, room, outside or wherever you would like to know the temperature.

You would probably want to use one of these if you’re planning on making an Arduino clock for example. Bundled with the temperature sensor and a button you could make a smart clock where you can press a button to get the current temperature. One step further would be to add a speaker and have it also act as an alarm clock.

I have covered an Arduino dice circuit before but instead of using the LED’s you could use the LCD to display the outcome of the roll. Just keep the switch and replace the rest with the screen.

There is a huge amount of potential for what you’re able to do with an LCD. I will be looking at future projects that incorporates this cool part.

Now I hope you now have an Arduino LCD display hooked up and working correctly. If I have got anything wrong or you just have some feedback or something to add then please don’t hesitate to leave a comment below.

33461632e1701222d8a8a42ec3d4cee4UUUUUUUU

Subscribe & Get 21 Awesome Arduino Projects

Enter your email below to get instant access to 21 amazing Arduino projects.

Please check your inbox or junk mail for a confirmation email!