Lab 10
Lab 10
Equipment:
Personal Computer
Proteus software
Microchip Studio
Theory:
In this lab we would be mainly using Liquid Crystal display. The basic pins connections are
displayed below:
It contains total of 16 pins. The general description of the pins is given in the below table
Page 2 of 6
In order to read or write the data we need to do certain command. All these functions can be easily
implemented through the following functions:
1) Command Function:
This function will set the LCD for certain command by performing the following operations:
First enables the command mode
Then sends the common to the LCD
Then set’s the enable pin to LOW
2) Data Function:
This function will send some data to the LCD through the data pins by performing the following
operations:
First enables the data mode
Then sends the data through the data pins
Then set’s the enable to LOW
3) Print Function:
This function is used to pass a string bit by bit to the LCD so that it could be written on the LCD.
Its function is based on the for loop and the data function.
Using these concepts and the basic LCD commands given in the data sheet we would be able to write
different string on the LCD according to our needs.
Page 3 of 6
In-Lab Task
To write cod for interfacing LCD and Simulate the project
Procedure:
First the new project was created
Then libraries were included
Command function was defined
Data function was defined
Print function was defined
Then though proper commands the string was passed to the LCD
Proteus circuit was designed for the project
The code was uploaded to the microcontroller and the project was simulated.
Code:
#include <avr/io.h>
#define F_CPU 16000000UL
#include <util/delay.h>
#include <string.h>
_delay_ms(20);
PORTC = 0x01;
_delay_ms(20);
int main(void)
DDRC = 0XFF;
DDRD = 0XFF;
Page 4 of 6
CommondMode(0x38); //activate 2 lines
CommondMode(0x0F); //display is on cursor is blinking
CommondMode(0x01); //clear display
while (1)
_delay_ms(20);
_delay_ms(1000);
CommondMode(01);}}}
Result:
Results:
As a result of the lab we were able to give different command to the LCD using the command function
and set data through the data function. Also, we printed the string on the LCD using the print
function. Thus, the objectives of the label were achieved .
Page 5 of 6
Page 6 of 6