Arduino LCD Tutorial _ How to Connect an LCD to Arduino
Arduino LCD Tutorial _ How to Connect an LCD to Arduino
MENU
Arduino 16×2 LCD Tutorial – Everything You
Need to Know
by Dejan • 25 Comments
In this Arduino tutorial we will learn how to connect and use an LCD
(Liquid Crystal Display) with Arduino. LCD displays like these are very
popular and broadly used in many electronics projects because they are
great for displaying simple information, like sensors data, while being very
affordable.
Table of contents
1. What is LCD Character Display?
2. 16×2 LCD Pinout
3. How to Connect Arduino to LCD – Wiring Diagram
4. Adjusting the contrast of the LCD
4.1. Can I use the LCD without Potentiometer?
5. LCD Arduino Code
6. Scrolling text example on 16×2 LCD and Arduino
7. How to Generate and Display Custom Characters on the LCD
8. Conclusion
I’ve already used them in several of my Arduino projects, and you can
check them out here:
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 1/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
You can watch the following video or read the written tutorial below. It
includes everything you need to know about using an LCD character
display with Arduino, such as, LCD pinout, wiring diagram and several
example codes.
If we take a closer look at the display we can notice that there are small
rectangular areas composed of 5×8 pixels grid. Each pixel can light up
individually, and so we can generate characters within each grid.
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 2/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
The number of the rectangular areas define the size of the LCD. The most
popular LCD is the 16×2 LCD, which has two rows with 16 rectangular
areas or characters. Of course, there are other sizes like 16×1, 16×4, 20×4
and so on, but they all work on the same principle. Also, these LCDs can
have different background and text color.
Next, The RS pin or register select pin is used for selecting whether we will
send commands or data to the LCD. For example if the RS pin is set on low
state or zero volts, then we are sending commands to the LCD like: set the
cursor to a specific location, clear the display, turn off the display and so
on. And when RS pin is set on High state or 5 volts we are sending data or
characters to the LCD.
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 3/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
Next comes the R/W pin which selects the mode whether we will read or
write to the LCD. Here the write mode is obvious and it is used for writing
or sending commands and data to the LCD. The read mode is used by the
LCD itself when executing the program which we don’t have a need to
discuss about it in this tutorial.
Next is the E pin which enables the writing to the registers, or the next 8
data pins from D0 to D7. So through this pins we are sending the 8 bits
data when we are writing to the registers or for example if we want to see
the latter uppercase A on the display we will send 0100 0001 to the
registers according to the ASCII table. The last two pins A and K, or anode
and cathode are for the LED back light.
After all we don’t have to worry much about how the LCD works, as the
Liquid Crystal Library takes care for almost everything. From the Arduino’s
official website you can find and see the functions of the library which
enable easy use of the LCD. We can use the Library in 4 or 8 bit mode. In
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 4/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
this tutorial we will use it in 4 bit mode, or we will just use 4 of the
8 data
pins.
We will use just 6 digital input pins from the Arduino Board. The LCD’s
registers from D4 to D7 will be connected to Arduino’s digital pins from 4
to 7. The Enable pin will be connected to pin number 2 and the RS pin will
be connected to pin number 1. The R/W pin will be connected to Ground
and the Vo pin will be connected to the potentiometer middle pin.
You can get these components from any of the sites below:
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 5/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
Yes, in case we don’t have a potentiometer, we can still adjust the LCD
contrast by using a voltage divider made out of two resistors. Using the
voltage divider we need to set the voltage value between 0 and 5V in
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 6/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
There’s also another way of adjusting the LCD contrast, and that’s by
supplying a PWM signal from the Arduino to the Vo pin of the LCD. We
can connect the Vo pin to any Arduino PWM capable pin, and in the setup
section, we can use the following line of code:
analogWrite(11,100); // Generate PWM signal at pin D11, value of 100 (out of 255)
It will generate PWM signal at pin D11, with value of 100 out of 255, which
translated into voltage from 0 to 5V, it will be around 2V input at the Vo
LCD pin.
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 7/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
/*
* Arduino LCD Tutorial
*
* Crated by Dejan Nedelkovski,
* www.HowToMechatronics.com
*
*/
void setup() {
lcd.begin(16,2); // Initializes the interface to the LCD screen, and specifies the dimensions (width and
}
void loop() {
lcd.print("Arduino"); // Prints "Arduino" on the LCD
delay(3000); // 3 seconds delay
lcd.setCursor(2,1); // Sets the location at which subsequent text written to the LCD will be displayed
lcd.print("LCD Tutorial");
delay(3000);
lcd.clear(); // Clears the display
lcd.blink(); //Displays the blinking LCD cursor
delay(4000);
lcd.setCursor(7,1);
delay(3000);
lcd.noBlink(); // Turns off the blinking LCD cursor
lcd.cursor(); // Displays an underscore (line) at the position to which the next character will be written
delay(4000);
lcd.noCursor(); // Hides the LCD cursor
lcd.clear(); // Clears the LCD screen
}
Code description:
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 8/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
In the loop we write our main program. Using the print() function
we print
on the LCD.
lcd.setCursor(2,1); // Sets the location at which subsequent text written to the LCD will be displayed
The blink() function is used for displaying a blinking cursor and the
noBlink() function for turning off.
The cursor() function is used for displaying underscore cursor and the
noCursor() function for turning off. Using the clear() function we can clear
the LCD screen.
#include <LiquidCrystal.h>
LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 9/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
void setup() {
lcd.begin(16, 2);
lcd.print("Scrolling Text Example");
}
void loop() {
lcd.scrollDisplayLeft();
delay(500);
}
We can choose whether the text will scroll left or right, using the
scrollDisplayLeft() or scrollDisplayRight() functions. With the delay()
function we can set the scrolling speed.
If you want more control over how the text is scrolling, you could also
make the scrolling on your own using a “for” loop. Here’s an example:
#include <LiquidCrystal.h>
LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LCD object. Parameters: (rs, enable, d4, d5, d6, d7)
void setup() {
lcd.begin(16, 2); // Initializes the interface to the LCD screen, and specifies the dimensions (width an
void loop() {
// scroll text to the right
for (int i = 0; i <= 13; i++) {
lcd.setCursor(i, 0); // Sets the location at which subsequent text written to the LCD will be displayed
lcd.print("LCD");
delay(500); // 1 second delay
lcd.clear(); // Write a character to the LCD
}
// scroll text to the left
for (int i = 12; i >= 1; i--) {
lcd.setCursor(i, 0);
lcd.print("LCD");
delay(500);
lcd.clear();
}
}
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 10/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
#include <LiquidCrystal.h>
byte smile[8] = {
B00000,
B00000,
B01010,
B00000,
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 11/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
B10001,
B01110,
B00000,
B00000
};
byte lock[8] = {
B01110,
B10001,
B10001,
B11111,
B11011,
B11011,
B11111,
B00000
};
byte character[8] = {
B11111,
B10101,
B11111,
B01010,
B01110,
B11111,
B01110,
B01110
};
LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Creates an LC object. Parameters: (rs, enable, d4, d5, d6, d7)
void setup() {
lcd.begin(16, 2); // Initializes the interface to the LCD screen, and specifies the dimensions (width an
lcd.createChar(0, heart); // Create a custom character
lcd.createChar(1, smile);
lcd.createChar(2, lock);
lcd.createChar(3, character);
void loop() {
lcd.setCursor(1, 1);
lcd.write(byte(0)); // Display the custom character 0, the heart
lcd.setCursor(5, 1);
lcd.write(byte(1));
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 12/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
lcd.setCursor(9, 1);
lcd.write(byte(2));
lcd.setCursor(13, 1);
lcd.write(byte(3));
}
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 13/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
We write the custom character to the display using the write() function
and as a parameter we use the number of the character.
Conclusion
So, we have covered pretty much everything we need to know about using
an LCD with Arduino. These LCD Character displays are really handy for
displaying information for many electronics project. In the examples above
I used 16×2 LCD, but the same working principle applies for any other size
of these character displays.
I hope you enjoyed this tutorial and learned something new. Feel free to
ask any question in the comments section below and don’t forget to check
out my full collection of 30+ Arduino Projects.
Arduino Tutorials
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 14/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
Ekin
April 1, 2020 at 7:43 pm
Hello! I know it is late but I have to ask this question, my lcd only
shows blue screen I checked wires tons of times and tried to adjust
potentiometer but not works. I hope you could help me
Reply
Dejan
April 2, 2020 at 10:11 am
Hey, well you have already tried the recommended things when it
comes to that problem, only blue screen. Very often it’s problem
with the contrast, but you said you have tried with a
potentiometer. Try also by making a 3.3v voltage divider using two
resistors. Also the problem might be something else, maybe your
LCD have a different driver on its board that might not be
compatible with this example, I don’t know, maybe. Or maybe,
your LCD is faulty one.
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 15/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
Reply
Brian
January 27, 2020 at 5:49 pm
Reply
ISaiD
March 14, 2019 at 3:57 pm
void setup() {
some code here;
analogWrite(your VO pin, 50);
some code here too;
}
Reply
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 16/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
wayan kw
May 9, 2018 at 3:16 am
Reply
Dejan Nedelkovski
May 9, 2018 at 8:51 am
Yes, you can remove it, but you will need to set two resistors as a
voltage dividers to get the proper voltage for getting the proper
contrast of the LCD.
Reply
Arduino is Life
September 24, 2021 at 7:49 pm
how do you make the voltage divider and what are the values of
the resistors?
Reply
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 17/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
Muhammad Malik Bilal
February 24, 2018 at 1:57 pm
Reply
John McGraw
March 16, 2017 at 2:58 pm
Have no experience with writing code but you have made it easier
to understand the basics, TY Dejan!
Reply
Dejan Nedelkovski
March 21, 2017 at 10:15 am
Reply
Hamza
November 5, 2016 at 11:10 am
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 18/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
I made it ! finally, it is working !
But you should not connect Anode to Vcc directly, since there is a
LED, so may burn it. You need a resistor of 220 Ohm, and you can
increase the resistance of you want a dimmer backlight. I connected
my resistor to a PMW port to control the backlight from the code.
Reply
Dejan Nedelkovski
November 9, 2016 at 12:25 am
Reply
lioooo
October 17, 2016 at 5:32 pm
Reply
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 19/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
Dejan Nedelkovski
October 18, 2016 at 1:05 am
Not really, you can print something permanently, but sure you can
make a code that would display what you want even after
rebooting the LCD, for example, using the EEPROM of the Arduino
which can store data when the power is off.
Reply
Anggi
April 30, 2016 at 3:03 pm
Reply
Dejan Nedelkovski
May 2, 2016 at 8:19 am
Reply
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 20/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
Maria
March 23, 2016 at 10:11 am
Reply
Dejan Nedelkovski
March 24, 2016 at 10:42 pm
Reply
magic
February 15, 2016 at 4:20 pm
Reply
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 21/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
PP
February 3, 2016 at 7:58 pm
Reply
Dejan Nedelkovski
February 5, 2016 at 8:40 am
Reply
Brian
December 17, 2015 at 1:00 am
Reply
Dejan Nedelkovski
December 17, 2015 at 8:42 am
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 22/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
I’m glad to hear that. You are welcome!
Reply
Anjana Perera
August 7, 2016 at 7:06 am
I highly appreciate that your video for LCD. I like to know whether
you have upload video for LCD though I2C module?. if so kindly
pass me a link (URL)
Reply
Dejan Nedelkovski
August 14, 2016 at 10:13 pm
Reply
Leave a Comment
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 23/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
Name *
Email *
Website
Post Comment
Hey I'm Dejan, a maker, a techie and a mechatronics engineer. I love making
electronics and robotics projects for you to learn and make something cool on
your own.
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 24/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
MY FAVORITE 3D PRINTER
MY TOOLS RECOMMENDATIONS
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 25/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
FEATURED PROJECTS
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 26/27
3/27/25, 11:38 PM Arduino LCD Tutorial | How To Connect an LCD to Arduino
How To Mechatronics
Disclosure
Copyright © 2025 HowToMechatronics.com. All rights reserved. Terms and Conditions | Privacy Policy
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/#what-is-lcd-character-display 27/27