0% found this document useful (0 votes)
82 views6 pages

Lab 10

This lab report describes interfacing a liquid crystal display (LCD) with a microcontroller. The objectives were to learn about LCDs, how to connect one, basic LCD commands, and writing code to control an LCD. The student defined functions for sending commands and data to the LCD and a print function to display strings. They wrote code to initialize the LCD, clear it, and print two lines of text. In simulation, the LCD correctly displayed the strings, achieving the lab objectives.

Uploaded by

Dark Phenix
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views6 pages

Lab 10

This lab report describes interfacing a liquid crystal display (LCD) with a microcontroller. The objectives were to learn about LCDs, how to connect one, basic LCD commands, and writing code to control an LCD. The student defined functions for sending commands and data to the LCD and a print function to display strings. They wrote code to initialize the LCD, clear it, and print two lines of text. In simulation, the LCD correctly displayed the strings, achieving the lab objectives.

Uploaded by

Dark Phenix
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

DEPARTMENT OF MECHATRONICS ENGINEERING UET PESHAWAR

Mte-318L Microcontrollers & Embedded Systems Lab, 5 th Semester


Name: Zaid Ahmed Registration Number: 20PWMCT0760
Lab Instructor: Ma,am Gulbadan Sikandar
Date: 26/12/2022

Lab no: 10:


LCD Interfacing:

Lab Report Rubrics:


Lab 10:
LCD Interfacing:
Objectives:
 To learn about the Liquid Crystal Display (LCD)
 To learn the connection of the LCD
 To know basic LCD commands
 To write C coding for the LCD
 To simulate the LCD circuit in the Proteus Professional

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:

Figure 10.1 LCD Labeled pins

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>

void CommondMode(char cmd){

PORTC = 0x02; //command mode enable high


PORTD = cmd;

PORTC = 0X00; // command mode enable low

_delay_ms(20);

void DataMode(char data){

PORTC = 0X03; //data mode enable high RS


PORTD = data;

PORTC = 0x01;

_delay_ms(20);

void lcd_print(char p[]){

for(int i=0; i<strlen(p); i++){


DataMode(p[i]);

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)

CommondMode(0x80); // force cursor to first line


lcd_print("Midrar");

_delay_ms(20);

CommondMode(0xC0);//force cursor to first positon of second line


lcd_print("Ullah");

_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

You might also like