Sie sind hier: Heim / Arduino LCD Display Tutorial

Arduino LCD Display Tutorial

Juli 13, 2026

Arduino LCD Display Tutorial: How to Connect and Program a 16x2 LCD

LCD displays are widely used in Arduino projects because they provide a simple and reliable way to show sensor readings, Systemstatus, Menüs, Nachrichten, and other information. A 16x2 character LCD is one of the most popular choices for beginners. It can display 16 characters on each of its two rows and is suitable for electronic prototypes, eingebettete Systeme, Messgeräte, Bedienfelder, und DIY-Projekte.

This Arduino LCD display tutorial explains how to connect a standard 16x2 LCD to an Arduino, upload a basic program, display changing values, and solve common display problems. It also introduces the easier I2C connection method.

Components Required

To complete this project, prepare the following components:

  • Arduino Uno or compatible development board
  • 16x2 character LCD module
  • 10K potentiometer
  • 220-ohm resistor
  • Steckbrett
  • Überbrückungsdrähte
  • USB cable
  • Arduino IDE

Most 16x2 LCD modules use an HD44780-compatible controller. These displays normally include 16 pins for power, data communication, contrast adjustment, and backlight control.

Understanding the 16x2 LCD Pins

A standard 16x2 LCD usually has the following pin arrangement:

  1. VSS – Ground
  2. VDD – 5V power supply
  3. VO – Contrast adjustment
  4. RS – Register Select
  5. RW – Read or Write control
  6. E – Enable pin
  7. D0 – Data pin
  8. D1 – Data pin
  9. D2 – Data pin
  10. D3 – Data pin
  11. D4 – Data pin
  12. D5 – Data pin
  13. D6 – Data pin
  14. D7 – Data pin
  15. A – Backlight anode
  16. K – Backlight cathode

LCD can operate in either 8-bit mode or 4-bit mode. For most Arduino projects, 4-bit mode is preferred because it requires fewer Arduino pins. In 4-bit mode, only data pins D4, D5, D6, and D7 are used.

Connecting the LCD to Arduino

Use the following wiring arrangement for a standard 16x2 LCD in 4-bit mode:

LCD PinArduino Connection
VSSGND
VDD5V
VOMiddle pin of 10K potentiometer
RSDigital pin 12
RWGND
EDigital pin 11
D4Digital pin 5
D5Digital pin 4
D6Digital pin 3
D7Digital pin 2
A5V through a 220-ohm resistor
KGND

Connect the two outer pins of the potentiometer to 5V and GND. The middle pin connects to the LCD VO pin. Rotating the potentiometer changes the display contrast.

The resistor connected to the backlight helps limit current. Some LCD modules already include a backlight resistor, but using an external resistor is a safer option when the module specifications are unknown.

Installing the Arduino LCD Library

The Arduino IDE includes the standard LiquidCrystal library. This library allows the Arduino to control HD44780-compatible character displays without manually programming every communication signal.

To include the library in your sketch, add the following line:

#include <LiquidCrystal.h>

Nächste, define which Arduino pins are connected to the LCD:

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

The pin order is:

LiquidCrystal lcd(RS, E, D4, D5, D6, D7);

Basic Arduino LCD Program

Upload the following code to display a simple message:

#include <LiquidCrystal.h>

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

void setup() {
  lcd.begin(16, 2);
  lcd.print("Hello, Arduino!");
}

void loop() {
}

Der lcd.begin(16, 2) command tells the Arduino that the display contains 16 columns and two rows. Der lcd.print() command writes text to the screen.

After uploading the program, the first row should display:

Hello, Arduino!

If the backlight turns on but no text appears, slowly rotate the potentiometer until the characters become visible.

Displaying Text on the Second Row

The LCD cursor can be moved by using the lcd.setCursor() function.

The format is:

lcd.setCursor(column, row);

The column and row positions start from zero. daher, the first character of the first row is position 0, 0, while the first character of the second row is position 0, 1.

Example:

#include <LiquidCrystal.h>

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

void setup() {
  lcd.begin(16, 2);

  lcd.setCursor(0, 0);
  lcd.print("LCD Tutorial");

  lcd.setCursor(0, 1);
  lcd.print("Arduino Project");
}

void loop() {
}

This program displays one message on each row.

Displaying a Changing Counter

LCD modules can display changing values such as temperature, voltage, Geschwindigkeit, Zeit, distance, or sensor data. The following program creates a simple counter:

#include <LiquidCrystal.h>

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

int counter = 0;

void setup() {
  lcd.begin(16, 2);
  lcd.print("Counter:");
}

void loop() {
  lcd.setCursor(0, 1);
  lcd.print("                ");

  lcd.setCursor(0, 1);
  lcd.print(counter);

  counter++;
  delay(1000);
}

The blank spaces clear the previous number before the new value is displayed. This prevents old characters from remaining on the screen when the number becomes shorter.

Displaying Sensor Data

One of the most common Arduino LCD applications is displaying analog sensor values. A potentiometer, light sensor, pressure sensor, or other analog device can be connected to an Arduino analog input.

The following example reads an analog signal from pin A0:

#include <LiquidCrystal.h>

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

void setup() {
  lcd.begin(16, 2);
  lcd.print("Sensor Value:");
}

void loop() {
  int sensorValue = analogRead(A0);

  lcd.setCursor(0, 1);
  lcd.print("                ");

  lcd.setCursor(0, 1);
  lcd.print(sensorValue);

  delay(500);
}

The Arduino Uno analog-to-digital converter normally returns a value from 0 Zu 1023. This value can also be converted into voltage:

float voltage = sensorValue * (5.0 / 1023.0);

The voltage can then be displayed with:

lcd.print(voltage, 2);
lcd.print(" V");

The number 2 tells the Arduino to display two digits after the decimal point.

Useful LiquidCrystal Commands

The LiquidCrystal library provides several useful functions:

Clear the Display

lcd.clear();

This removes all characters and returns the cursor to the first position.

Move the Cursor

lcd.setCursor(5, 1);

This moves the cursor to column five on the second row.

Turn the Display Off

lcd.noDisplay();

Turn the Display On

lcd.display();

Enable Cursor Display

lcd.cursor();

Enable a Blinking Cursor

lcd.blink();

Scroll Text

lcd.scrollDisplayLeft();
lcd.scrollDisplayRight();

These commands can be used to create menus, Warnmeldungen, scrolling text, and interactive interfaces.

Using an I2C LCD Module

Standard LCD connection uses at least six Arduino signal pins. An I2C adapter reduces the connection to only four wires:

  • VCC
  • GND
  • SDA
  • SCL

On an Arduino Uno, SDA is normally connected to A4 and SCL is connected to A5. Some boards also provide dedicated SDA and SCL pins.

Typical I2C LCD program looks like this:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  lcd.init();
  lcd.backlight();

  lcd.setCursor(0, 0);
  lcd.print("Hello Arduino");

  lcd.setCursor(0, 1);
  lcd.print("I2C LCD");
}

void loop() {
}

The I2C address is commonly 0x27 oder 0x3F, but it may vary. If the display does not respond, an I2C scanner program can be used to identify the correct address.

The exact initialization command may also depend on the installed I2C library version.

Common Arduino LCD Problems

Backlight Is On but No Text Appears

Stellen Sie das Kontrastpotentiometer ein. Incorrect contrast is one of the most common reasons for an apparently blank LCD.

Black Rectangles Appear

Black rectangles usually mean that the LCD has power but is not receiving the correct initialization commands. Check the RS, E, D4, D5, D6, and D7 connections.

Random or Corrupted Characters

Loose wires, incorrect pin definitions, unstable power, or poor breadboard connections can cause corrupted characters.

Text Does Not Update Correctly

Clear the previous value before displaying new data. You can use lcd.clear(), but repeatedly clearing the entire screen may cause visible flickering. Printing blank spaces over the previous value is often smoother.

I2C LCD Does Not Work

Check the SDA and SCL connections, confirm the I2C address, install a compatible library, and make sure the backlight has been enabled in the program.

Arduino LCD Project Ideas

After completing the basic tutorial, the LCD can be used in many projects, einschließlich:

  • Digital thermometers
  • Humidity monitors
  • Battery voltage meters
  • Distance measurement systems
  • Electronic clocks
  • Motor control panels
  • Smart energy meters
  • Alarm systems
  • Menu-based controllers
  • Industrial monitoring equipment

Buttons, rotary encoders, Sensoren, and communication modules can also be added to create a complete user interface.

Abschluss

Connecting a 16x2 LCD to an Arduino is an excellent introduction to display control and embedded system programming. A standard parallel LCD offers simple operation and reliable performance, while an I2C LCD saves Arduino pins and reduces wiring.

By learning how to initialize the display, position the cursor, print text, update changing values, and troubleshoot common problems, you can add a practical visual interface to almost any Arduino project. Whether you are building a sensor monitor, electronic instrument, control panel, or educational prototype, a character LCD provides a clear and cost-effective display solution.

--- ENDE ---
Aktie: