2. OBJECTIVES
1. Describe LCDs mode of operation and to interface
with PIC Microcontroller
2. Construct a program code to send commands and
data to LCD
3. Describe 4 x 4 Matrix keypad basic of operation
4. Illustrate key press detection and key identification
mechanism
5. Apply program code to Write keypad and display to
LCD in C programming
3. LCD Interfacing
• LCD stands for Liquid Crystal Display
???????????????????
• Most LCDs with one controller have 14 pins or 16 pins
• Two extra pins are for back-light LED connections while LCDs with
two controllers have two more pins to enable the additional controller
• Most commonly used character based LCDs are based on
Hitachi’s HD44780 controller or other which are compatible with
HD44580.
4. LCD Control lines
The three control lines are
referred to as EN, RS, and RW.
The EN line is called “Enable.”
-to tell the LCD that you are
sending in data.
-To send data to the LCD, your
program should make sure this line
is low (0) and then set the other two
control lines and/or put data on the
data bus.
-When the other lines are
completely ready, bring EN high (1)
and wait for the minimum amount of
time required by the LCD datasheet
and end by bringing it low (0)
again.
5. RS & RW & DATA BUS ???
The RS line is the “Register Select” line. When RS is low (0), the data is to
be treated as a command or special instruction (such as clear screen,
position cursor, etc.). When RS is high (1), the data being sent is text data
which sould be displayed on the screen. For example, to display the letter
“T” on the screen you would set RS high.
The RW line is the “Read/Write” control line. When RW is low (0), the
information on the data bus is being written to the LCD. When RW is high
(1), the program is effectively querying (or reading) the LCD. Only one
instruction (“Get LCD status”) is a read command. All others are write
commands–so RW will almost always be low.
The data bus consists of 4 or 8 lines (depending on the mode of
operation selected by the user). In the case of an 8-bit data bus, the
lines are referred to as DB0, DB1, DB2, DB3, DB4, DB5, DB6, and
DB7.
7. LCD hardware connection to PIC microcontroller
RB5, RB6 and RB7 of PIC are used for the control signals while
PORTD of the microcontroller is the data bus.
11. Keypad Interfacing
• Matrix keypads are very useful when designing certain
system which needs user input.
• By arranging push button switches in rows and columns.
• To scan which button is pressed, we need to scan it column by column
and row by row.
• Make rows as input and columns as output.
• For keypad wiring , need to pull up or pull down to avoid floating.
Pull-up R
Active HIGH
Pull-down R
Active LOW
19. Question ??
1.Give the combination ROW & COL for:
i. Keypad number 5 ROW2 & COL2
ii. Keypad # ROW4 & COL3
iii. Keypad B ROW2 & COL4
2. State the ASCII key for this arrangement
keypad press:
i. Row2 & Col3 case ASCII code= 54 // => 6
ii. Row3 & Col4 case ASCII code= 67 // => C