How to control an LCD display with Arduino

LCD displaying "www.comohacer.eu"

We spend many hours sitting in front of screens, but few understand how they actually work. In this post we will show you how to programme a LCD display with an Arduino boardThis allows you to display messages on the screen and even use the functions of the LiquidCrystal library to create effects and display images.

This will be very useful, especially if you have a more complex project in mind where you need to display data on screenThe information obtained by different sensors connected to the Arduino, for example, can be used to monitor all this information and much more. You can monitor all this information and much more.

Materials

  • Arduino UNO Rev3. (Buy it in our shop)
  • An LCD (Liquid Crystal Display). In our case we will use a 16×2 (Columns x Rows) LCD, which are the most common. I will use a LCM1602C.
  • Single-line connection wires.
  • One 10K potentiometerΩ.
  • A breadboard or protoboard to make connections more conveniently.
  • Arduino IDE installed on our Raspberry Pi, PC or Mac, in order to make the sketch.

Procedure

The LCD screen connected to the Arduino will allow us to display text in a simple way. The Arduino platform has libraries such as "LiquidCrystal"(written by Limor Fried) that allows you to control LCD displays compatible with the driver. Hitachi HD44780 (very common in the market). What we will do is to display the message ComoHacer.eu on screen, but you can modify it to show what you want.

If you look at the LCD screen you have, it usually has inscriptions on the front or back indicating what each of these is. connection pin. In my case it comes from the back, as you can see in the following illustration:

Pins of the LCM1602C

Note: If you are not sure, you can look at the model of LCD screen you have and search on Google to access or download the datasheet (pdf) of your screen. In this document, the manufacturer will give you all the information you need to make it work.

It can be seen that in the case of the LCM1602C the numbering of the connection pins starts from right to left, but from the back! (16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1). If we continue observing we can see that pin 1 corresponds to GND, pin 2 to the voltage input Vdd, pin 3 to Vo, pin 4 to RS, pin 5 to RW, pin 6 to E, pin 7-14 to Dbx, pin 15 to BL1 and pin 16 to BL2. A priori, if you haven't handled LCD screens, it will sound like a Chinese thing, but now I'll explain what each thing is:

  • RS (Register Select)The memory pin is the pin that controls the memory of the LCD, and indicates which memory register will be read or written. From this memory you get the data to display on the screen, but you also get instructions that the LCD controller needs to act.
  • RW (Read/Write): is the read/write pin, which will tell whether it is written to memory or read at any given time.
  • E (Enable): pin that enables registrations.
  • DB0-DB7: are the data pins, from which the bits that reach the register are taken. In the case of the display I have, it designates them as DB0-DB7 and they correspond to the numbering 7-14, but this may vary depending on the manufacturer or model of the LCD. For example, in some I have seen that they designate it as DO0-D07.
  • Vo: is the contrast pin of the display, with which we can modify the contrast of the screen.
  • Vdd: is the power supply pin, which supplies the voltage that will operate the LCD. Normally it is +5v.
  • GND: complements the previous pin, with the other power supply pin to be connected to ground.
  • BL1 and BL2: are the backlight pins. They control the brightness of the LCD. On some displays they may appear with the symbols Bklt+ and Bklt-. The abbreviation stands for "Back Light".

At first it all seems a bit tedious, but it's simple. It's just that there is too much information to give to be clear about how the screen works, but once you know how it works, it's a piece of cake.

Now that you should be clear on what each pin is for, let's explain how it should be used. make the connection for our example (it is not the only one, you can add thousands of other elements or even make the connection in other possible ways). What we will do is to connect the LCD screen to a breadboard to make the connection easier. Then we will connect the RS pin to the Arduino digital I/O 12 and the E pin to the Arduino digital I/O number 11 with the single wires. We connect the DB4-DB7 data pins to the digital I/O from 5 to 2 (i.e. 4-5 / 5-4 / 6-3 / 7-2, the rest of the DB0-DB3 data pins will not be connected as we will only work with 4 bits instead of 8). We continue by connecting, respectively, the Vdd and GND pins to the +5V and GND outputs of the Arduino board. We will then connect the Vo pin to the centre pin of a potentiometer (which in turn will have the end pins connected to +5V and GND), ignoring BL1 and BL2 which we will not use. As a picture is worth a thousand words...

Wiring diagram

Now we have everything, the circuit is created and everything is ready to make the sketch that programs its operation. Now it's time to use our computer or Raspberry Pi to write the necessary code in the Arduino IDE:

[cpp]

//LCD display control

#include //Library needed for LCDs

//Initialise the pins to be used
LiquidCrystal lcd(12,11,5,4,3,2);

void setup() {
///Express the number of columns and rows of our LCD.
lcd.begin(16, 2);
//Print the desired message on the LCD
lcd.print("Comohacer.eu");
}

void loop() {
//Prepare the cursor in column 0 of line 1
//This indicates where the text will start printing.
lcd.setCursor(0,1);
}

[/cpp]

And I will end by explaining something that I have not explained before, which is the functionality of the potentiometer. It will help you to adjust the contrast, the screen may not have a good contrast if you don't adjust it and the text may not look good. Try moving it around until you are happy with the result. Best of luck and happy disproject!

Buy - Arduino UNO rev. 3

More information - Arduino control via Raspberry Pi

9 thoughts on “Cómo controlar una pantalla LCD con Arduino”

  1. oscar de la rosa

    Sorry when I enter the program I mark errors 🙁 and try several ways but I still marking error ... that is due to that? or if you have already done the program do you think I can pass it? is the same display that I work, would be of great help, for your attention Thank you.

  2. Marco alvarez

    How can I make the message come out from different potentiometer positions and therefore from different positions on the screen?

Leave a Comment

Your email address will not be published. Required fields are marked *

en_GBEnglish
Scroll to Top