You are on page 1of 9

ECE 2030

Arduino Based System


Design

Daw Khaing Su Wai


Experiment 11

Liquid Crystal Display LCD Controller


Liquid Crystal Display (LCD)

• Liquid crystal displays (LCDs) are a commonly used to display data in devices such as calculators,
microwave ovens, and many other electronic devices.
• The LCDs have a parallel interface, meaning that the microcontroller has to manipulate several
interface pins at once to control the display.
The interface consists of the following pins:
• A register select (RS) pin that controls where in the LCD's memory you're writing data to. You can
select either the data register, which holds what goes on the screen, or an instruction register,
which is where the LCD's controller looks for instructions on what to do next.
• A Read/Write (R/W) pin that selects reading mode or writing mode
• An Enable pin that enables writing to the registers 8 data pins (D0 -D7). The states of these pins
(high or low) are the bits that you're writing to a register when you write, or the values you're
reading when you read.
• Led+:Back light of the LCD which should be connected to Vcc or 5V.
• Led-:Back light of the LCD which should be connected to Gnd or 0V.
Liquid Crystal Display (LCD)
Liquid Crystal Display (LCD)

• It has 16 pins and the first one from left to right is the Ground pin.
• The second pin is the VCC which we connect the 5 volts pin on the Arduino Board.
• Next is the Vo pin on which we can attach a potentiometer for controlling the contrast of the
display.
• 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.
• Next comes the R / W pin which selects the mode whether we will read or write to the LCD.
• The write mode is obvious and it is used for writing or sending commands and data to the LCD.
• 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.
Liquid Crystal Display (LCD) Circuit Diagram
Liquid Crystal Display (LCD)
• LCD VSS pin to Arduino GND
• LCD VDD pin to Arduino 5V
• LCD RS pin to digital pin 12
• LCD RW pin to Arduino GND
• LCD Enable pin to digital pin 11
• LCD D4 pin to digital pin 5
• LCD D5 pin to digital pin 4
• LCD D6 pin to digital pin 3
• LCD D7 pin to digital pin 2
• Additionally, wire a 10k potentiometer to +5V and GND, with it's wiper (output) to LCD screens
VO pin (pin3).
Adding Text to the Display
• The Arduino IDE includes the Liquid Crystal library, a set of functions that makes it very easy to
interface with the parallel LCD that you are using.
• The Liquid Crystal library allows you to control LCD displays that are compatible.
• First include the LiquidCrystal library
#include <LiquidCrystal.h>
• Then, initialize an LCD object, as follows:
LiquidCrystallcd (2, 3, 4, 5, 6, 7);
• The arguments for the LCD initialization represent the Arduino pins connected to RS, EN, D4,
D5, D6, and D7, in that order.
• In the setup, you call the library’s begin() function to set up the LCD display with the character
size.
• (The one we are using is a 16×2 display, but you might be using another size, such as a 20×4).
The arguments for this command represent the number of columns and the number of rows,
respectively:
lcd.begin(16, 2);
Example : void setup(){
lcd.begin(16,2);
lcd.clear();}
Adding Text to the Display
• After doing that, you can call the library’s print() and setCursor()commands to print text to a
given location on the display. For example, if you want to print your name on the second line,
you issue these commands:
lcd.setCursor(0, 0);
lcd.print(“Mr.Arduino Uno”);
Example: void loop(){
lcd.setCursor(5,0);
lcd.print(“Hello!”);
lcd.setCursor(3,1);
lcd.print(“Good Day”);
Delay(1000);
lcd.clear();}
• The positions on the screen are indexed starting with (0,0) in the top-left position.
• The first argument of setCursor() specifies which column number, and the second specifies
which row number. By default, the starting location is (0,0).
• So, if you call print() without first changing the cursor location, the text starts in the top-left
corner.

You might also like