100% found this document useful (2 votes)
67 views4 pages

LCD Display

This program interfaces a microcontroller with a 16x2 LCD to display the character "A". It uses the microcontroller's ports to connect to the LCD's data and control pins. It initializes the LCD by sending commands, then sends the character data by calling the lcddata function. This displays a single character on the LCD to test the interfacing.

Uploaded by

hitesh_maxi
Copyright
© Attribution Non-Commercial (BY-NC)
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
100% found this document useful (2 votes)
67 views4 pages

LCD Display

This program interfaces a microcontroller with a 16x2 LCD to display the character "A". It uses the microcontroller's ports to connect to the LCD's data and control pins. It initializes the LCD by sending commands, then sends the character data by calling the lcddata function. This displays a single character on the LCD to test the interfacing.

Uploaded by

hitesh_maxi
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 4

LCD.

Display

A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in 5x7 pixel matrix.

1.

Command/Instruction Register- stores the command instructions given to the LCD. A command is an instruction given to LCD to do a predefined task like initializing, clearing the screen, setting the cursor position, controlling display etc.

2.

Data Register- stores the data to be displayed on the LCD. The data is the ASCII value of the character to be displayed on the LCD.

Programming the LCD:

1.

Data pin8 (DB7) of the LCD is busy flag and is read when R/W = 1 & RS = 0. When busy flag=1, it means that LCD is not ready to accept data since it is busy with the internal operations. Therefore before passing any data to LCD, its command register should be read and busy flag should be checked.

2.

To send data on the LCD, data is first written to the data pins with R/W = 0 (to specify the write operation) and RS = 1 (to select the data register). A high to low pulse is given at EN pin when data is sent. Each write operation is performed on the positive edge of the Enable signal.

3.

To send a command on the LCD, a particular command is first specified to the data pins with R/W = 0 (to specify the write operation) and RS = 0 (to select the command register). A high to low pulse is given at EN pin when data is sent.

Displaying single character A on LCD The LCD is interfaced with microcontroller (AT89C51). This microcontroller has 40 pins with four 8-bit ports (P0, P1, P2, and P3). Here P1 is used as output port which is connected to data pins of the LCD. The control pins (pin 4-6) are controlled by pins 2-4 of P0 port. Pin 3 is connected to a preset of 10k? to adjust the contrast on LCD screen. This program uses the above concepts of interfacing the LCD with controller by displaying the character A on it.

//Program to test LCD. Display single character "A"

#include<reg51.h> #define cmdport P3 #define dataport P2 #define q 100 sbit rs = cmdport^0; sbit rw = cmdport^1; sbit e = cmdport^6; //register select pin // read write pin //enable pin

void delay(unsigned int msec) { int i,j ; for(i=0;i<msec;i++) for(j=0;j<1275;j++); }

// Function to provide time delay in msec.

void lcdcmd(unsigned char item) { dataport = item; rs= 0; rw=0; e=1; delay(1); e=0;

//Function to send command to LCD

void lcddata(unsigned char item) { dataport = item; rs= 1; rw=0; e=1; delay(1); e=0; } void main() { lcdcmd(0x38); delay(100); lcdcmd(0x0E); delay(100); lcdcmd(0x01); delay(100); lcdcmd(0x06); delay(100); lcdcmd(0x86); delay(100); lcddata('A'); } //display ON //clear screen

//Function to send data to LCD

// for using 8-bit 2 row mode of LCD

// turn display ON for cursor blinking

// bring cursor to position 6 of line 1

You might also like