LCD & Keyboard

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

LCD Programming

16X2 LCD
• capable of displaying 2 lines each having 16 Characters
• It has two types of input lines: data line and control lines
• 8 data lines, 3 control lines: Register select, Read/Write and
Enable.
• In the kit that we are using, Read/ write is grounded-> used
for write.
Data Bus: 8-bit data bus referenced as D0-D7. As it is a 8-
bit data bus, we can send the data/cmd to LCD in bytes. It
also provides the provision to send the data/cmd in chunks of
4-bit, which is used when there are limited number of GPIO
lines on the microcontroller. Accordingly two modes of
operation: 8 bit mode and 4 bit mode
• The kit that we are using is in 4 bit mode. Data lines D7-D4
are used
Register Select(RS): The LCD has two registers namely a
Data register and Command register. Any data that needs to
be displayed on the LCD has to be written to the data register
of LCD. Command can be issued to LCD by writing it to
Command register of LCD. This signal is used to differentiate
the data/cmd received by the LCD.

If the RS signal is LOW then the LCD interprets the 8-bit info
as Command and writes it to Command register and
performs the action as per the command.

If the RS signal is HIGH then the LCD interprets the 8-bit info
as data and copies it to data register. After that the LCD
decodes the data for generating the 5x7 pattern and finally
displays on the LCD.
On a character lcd a character is generated in a matrix of
5×8 or 5×7. Where 5 represents number of columns and 7/8
represent number of rows. Maximum size of the matrix is
5×8. You can not display character greater then 5×8
dimension matrix. Normally we display a character in 5×7
matrix and left the 8th row for the cursor. If we use the 8th
row of the matrix for the character display, then there will be
no room for cursor.
Read/Write(RW): This signal is used to write the data/cmd
to LCD and read the busy flag of LCD. For write operation
the RW should be LOW and for read operation the R/W
should be HIGH.

• In the kit we cant read as it is grounded


Enable(EN): This pin is used to send the enable trigger
to LCD. After sending the data/cmd, A HIGH-to-LOW
pulse has to be send on this enable pin which will latch
the info into the LCD register and triggers the LCD to
act accordingly.
LCD display takes a time of 39-43µS to place a character or
execute a command. Except for clearing display and to seek
cursor to home position it takes 1.53ms to 1.64ms. Any
attempt to send any data before this interval may lead to
failure to read data or execution of the current data. So we
have to give appropriate delay after each command.
Note: The pin nos in the diagram are different with respect to the kit that we use in lab.
LCD Initialization
Before displaying characters on the LCD display, it must be
configured first. To configure an LCD display, four command
words must be sent to LCD. The commands are:
1. Function set
2. Display On/Off control
3. Entry mode set
4. Display Clear
• Our kit works in 4 bit mode.
• To send data in 4bit mode; first put upper 4bit in the
4 bit data bus connected to 4MSB pins of LCD
display, then put control signals in the control bus,
then pulse the E pin once. Next put the lower 4 bit
in the data bus and pulse the E pin again.
Before
function set,
we need to
configure in 4
bit mode
Control and display commands

Hex Command to LCD instruction


Sr.No.
Code Register
1 01 Clear display screen
2 02 Return home
Decrement cursor (shift cursor to
3 04
left)
Increment cursor (shift cursor to
4 06
right)
5 05 Shift display right
6 07 Shift display left
Hex Command to LCD instruction
Sr.No.
Code Register
7 08 Display off, cursor off
8 0A Display off, cursor on

9 0C Display on, cursor off


Display on, character at cursor position
10 0E
not blinking
Display on, character at cursor position
11 0F
blinking
12 10 Shift cursor position to left
Sr.No. Hex Code Command to LCD instruction Register

13 14 Shift cursor position to right


14 18 Shift the entire display to the left
15 1C Shift the entire display to the right
16 80 Force cursor to beginning ( 1st line)
17 C0 Force cursor to beginning ( 2nd line)
So we send 0x33 as the command code. This will do the
initial 8 bit mode starting of LCD. Now after this we need to
send 0x32.
LCD Interfacing (Video)
https://www.youtube.com/watch?v=WocACC9xZbI

Websites for LCD:


https://mil.ufl.edu/3744/docs/lcdmanual/commands.html
https://msoe.us/taylor/tutorial/ce2800/lcddisplay
https://www.exploreembedded.com/wiki/LPC1768:_Lcd_4bit
https://www.elprocus.com/lcd-16x2-pin-configuration-and-its-working/
https://openlabpro.com/guide/16x2-character-lcd-interfacing-using-
lpc1768/
The switches SW3 to SW18 are organized as 4 rows X 4
columns matrix. One end of all the switches are configured as
columns. The other end of the matrix configured as rows. A row
line will be always an output from the controller. Column lines
are pulled to ground. A high level sent from the row will
appear at column end if the switch is pressed.

You might also like