MP Lab04 - LCD PDF

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

Microprocessors Lab Manuals

Lab 04
Introduction and implementation of LCD interfacing on
ATMEGA16 microcontroller

Instructor
Asma Ramay
Department of Electrical Engineering CIIT, Islamabad

COMSATS Institute of Information Technology, Islamabad

Microprocessors Lab Manuals

Objectives:
Introduction to LCD interfacing with microcontroller.

Implementation of LCD interfacing with ATMEGA16 microcontroller.

Tools:
VMLab, Winavr, Proteus ISIS .
Liquid Crystal Display (LCD)
The most commonly used Character based LCDs are based on Hitachi's
HD44780 controller or other which are compatible with HD44580. Below
given is figure of such an LCD.

COMSATS Institute of Information Technology, Islamabad

Microprocessors Lab Manuals

LCD Pinout:

The table below provides the description of the pins:

COMSATS Institute of Information Technology, Islamabad

Microprocessors Lab Manuals

LCD Interfacing:

R/W pin is used select between the read or write operation. You can either
send command or either send the required data to display on the LCD. Since
same pins from D0 to D7 are used for both command and data, RS pin is used
to identify between the command and data.
To send command to LCD, we will first set RS pin to zero. If we want to send
data to LCD, we will set the RS pin as high. EN is enable pin which is used to
synchronize the whole operation of sending data or command to LCD. The
LCD will not read any pins for command or data until we give high to low
transition to enable pin. This is important because we want to make sure that
the data on the LCD pins is right before LCD reads it. By enable pin we can
control when LCD should read the data on its pins.
The above procedure for reading from or writing to LCD is illustrated with the
help of following timing diagrams:

COMSATS Institute of Information Technology, Islamabad

Microprocessors Lab Manuals

COMSATS Institute of Information Technology, Islamabad

Microprocessors Lab Manuals

LCD Command Set:

The table below summarizes command set of Hitachi 44780 based LCDs

The detailed description of some of these commands is given below:

COMSATS Institute of Information Technology, Islamabad

Microprocessors Lab Manuals

LCD Initialization:

The following initialization procedure is mentioned by the manufacturer of


this LCD:

The table below provides address for various display locations on a 16X4 LCD:

Finally ASCII chart containing character code for most commonly used
characters is given below:

COMSATS Institute of Information Technology, Islamabad

Microprocessors Lab Manuals

Microcontroller coding for LCD interfacing:

It is suggested that you make three subroutines in addition to main


subroutine in your code.
The subroutine for sending command to the LCD will look like:

The subroutine for sending character to the LCD will look like:

COMSATS Institute of Information Technology, Islamabad

Microprocessors Lab Manuals


The subroutine for initializing the LCD will look like:

COMSATS Institute of Information Technology, Islamabad

Microprocessors Lab Manuals

In Lab Task:

Interface a 16X4 LCD to the ATMEGA16 microcontroller and display your


name on it.

COMSATS Institute of Information Technology, Islamabad

10

Microprocessors Lab Manuals

Post Lab Task:

Interface a keypad and LCD to ATMEGA16. Scan the keypad for pressed
key and display it on LCD.

COMSATS Institute of Information Technology, Islamabad

11

You might also like