LCD ARDUINO

Photo of author

By Jackson Taylor

Home » Electronics Topics » Arduino » LCD ARDUINO

As an Amazon Associate we earn from qualifying purchases.

A character LCD is one of the easiest ways to give an Arduino project a readable output. You can show sensor readings, menu options or status messages without a computer attached. This guide shows how to wire a 16×2 LCD to an Arduino, explains a short working sketch, and covers the problems beginners most often run into.

What You Need

How a 16×2 LCD Works

A 16×2 display shows two rows of 16 characters. Each character is drawn in a small grid of dots, and the controller chip on the back of the module handles the drawing. You only send it commands and character codes.

The module can be driven in 8-bit or 4-bit mode. In 4-bit mode, only four data lines (D4 to D7) are used, which saves Arduino pins. The Arduino LiquidCrystal library, included with the Arduino IDE, uses this mode in the example below.

Hardware Hack

Stop Buying New Batteries for Your Tech

Electronics are expensive, but their power sources don't have to be. Discover the simple engineering trick to recondition dead batteries and bring your gadgets back to 100% capacity.

Watch the Free Video

LCD Pin Overview

  • VSS: ground
  • VDD: 5V
  • V0: contrast, connected to the middle pin of the potentiometer
  • RS: register select, tells the display whether you are sending a command or text
  • RW: read/write, tied to ground because we only write to the display
  • E: enable, the pin that latches the data
  • D0 to D3: not used in 4-bit mode
  • D4 to D7: data lines
  • A and K: backlight anode and cathode

Wiring the LCD to the Arduino

The example sketch below uses these connections:

  • LCD RS to Arduino pin 12
  • LCD E (Enable) to Arduino pin 13
  • LCD D4 to A0
  • LCD D5 to A1
  • LCD D6 to A2
  • LCD D7 to A3
  • LCD RW to ground
See also
PLOTTING DATA ON INTERNET USING PYTHON AND THINGSSPEAK.COM

The analog pins A0 to A3 can work as ordinary digital pins, so they are fine for the data lines. Also connect VSS to ground, VDD to 5V, and the two outer pins of the potentiometer to 5V and ground, with its middle pin going to V0. Connect the backlight anode (A) to 5V through the resistor and the cathode (K) to ground.

Example Code

This sketch prints the word EMERGING on both rows of the display:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 13, A0, A1, A2, A3);//LCD RS-12, En-13, D4-A0, D5-A1, D6-A2, D7-A3, R/W-ground
void setup()
{
    lcd.begin(16, 2);// set up the LCD's number of columns and rows:
    lcd.print("EMERGING");// Print a message to the LCD.
}
void loop()
{
    lcd.setCursor(0, 1);
    lcd.print("EMERGING");
}

How the Code Works

  1. #include <LiquidCrystal.h> loads the library that talks to the display.
  2. LiquidCrystal lcd(12, 13, A0, A1, A2, A3); creates the display object. The arguments are the pins for RS, Enable, D4, D5, D6 and D7, in that order. If your wiring differs, change these numbers to match.
  3. lcd.begin(16, 2); tells the library the display has 16 columns and 2 rows.
  4. lcd.print(“EMERGING”); writes the text at the current cursor position, which is the top-left corner after startup.
  5. lcd.setCursor(0, 1); moves the cursor to column 0 of the second row. Rows and columns count from zero.

The first word appears on the top row from setup(), and the second appears on the bottom row from loop(). Printing the same text again and again in loop() is not necessary here, since the text does not change. It is only useful as a demonstration. In a real project, the loop is where you update values such as a sensor reading.

Updating Values Without Flicker

If you print a changing number, a shorter value can leave old characters behind. For example, going from 100 to 99 may display “990”. There are two simple fixes:

  • Overwrite the whole field by printing extra spaces after the value.
  • Call lcd.setCursor() before each update so you always write to the same spot.
See also
bldc (brushless dc motor) sensorless control using arduino

Avoid calling lcd.clear() on every pass through the loop. It blanks the screen and makes the text flicker.

Common Problems and Fixes

The screen is lit but shows only blocks or nothing

This is almost always the contrast. Turn the potentiometer slowly until the characters appear. If you see a full row of solid blocks, the display is powered but has not been initialised, so check the RS and Enable wires and make sure lcd.begin() runs.

The display shows random characters

Check that the data wires go to the right pins. Swapped D4 to D7 lines are a common cause. Also confirm that the pin order in the LiquidCrystal line matches your wiring, and that the RW pin is grounded.

Nothing lights up at all

Check the 5V and ground connections for both the module and the backlight. A loose breadboard wire is also a frequent culprit.

Where to Go Next

Once the basic example works, you can add custom characters, scrolling text or sensor readings. For more wiring variations and sketches, see our guide to Arduino LCD displays. If you want a sharper screen with graphics, read about how LCD and OLED displays compare.

Sustainable Tech

Keep Toxic E-Waste Out of Landfills

Don't throw away your failing laptop, phone, or car batteries. Learn how to recondition them at home in just a few hours. It's better for the planet—and your wallet.

Learn How It Works

If you do not have the hardware at hand, you can simulate the circuit in Proteus first. There is also a project that shows how to show UART data on an LCD using Arduino.

FAQ

Which library do I use for an LCD with Arduino?

For a standard parallel HD44780 display, use LiquidCrystal. It comes with the Arduino IDE, so you do not need to install anything extra.

Can I use different pins from the example?

Yes. You can use almost any free digital pins. Just list them in the LiquidCrystal constructor in the order RS, Enable, D4, D5, D6, D7.

Why is the RW pin connected to ground?

Grounding RW puts the display in write mode. Arduino only sends data to the LCD and does not read from it, so this saves a pin.

See also
ARDUINO AND SERVO MOTOR INTERFACING SIMULATION IN PROTEUS

How can I use fewer wires?

An LCD with an I2C backpack needs only four connections: power, ground, SDA and SCL. It uses a different library and sketch setup than the parallel example above.

Revive Your Dead Electronics

Got a drawer full of dead gadgets or a failing car battery? Instead of paying a premium for replacements, use this simple trick to easily recondition them right from home.

See How It Works