LCD Interfacing with 8051 Microcontroller

Liquid crystal display interfacing with 8051 Microcontroller

INTRODUCTION:

  • It is a popular technology employed in various electronic devices as of the modern century.
  • It makes use of the light properties of liquid crystals.

ADVANTAGES:

  1. They consume less light than LED.
  2. They have more input connections compared to LED.
  3. Constant backlight and it works on the principle of blocking the light instead of emitting it, thus displaying the characters.

 

INTERFACING LCD WITH 8051:

  • The LCD can be interfaced with 8051 microcontroller chip to display many characters or strings in different languages.
  • It is employed in many public areas for displaying shop logos or boards so that it makes it attractive.
  • The corresponding connections are given.

CONNECTION PROCEDURE:

  1. Initially the connections are made as per the pin description table above.
  2. The reset pin( 9th pin) of the micro-controller is connected to the 5V port initially before powering on the circuit.
  3. After powering on the reset pin is connected to ground to enable the displaying of letters.
  4. My name is given as the string to be displayed on the LCD screen.
  5. The LCD initialisation process takes place first after that command is given for cursor and positioning cursor.
  6. Finally the data is displayed using PORT  of the micro-controller with a delay of 50 ms between each letter of “KEVIN MATHEW”.
Program for LCD Interfacing with 8051 Microcontroller (AT89S52)

#include<reg51.h>

#define display_port P1 //Data pins connected to port 2 on microcontroller

sbit rs = P0^2;  //RS pin connected to pin 2 of port 3

sbit rw = P0^3;  // RW pin connected to pin 3 of port 3

sbit e =  P0^4;

sbit DB0= P3^0;

sbit DB1 = P3^1;

sbit DB2= P3^2;

sbit DB3=P3^3;

sbit DB4 =P3^4;

sbit DB5 =P3^5;

sbit DB6=P3^6;

sbit DB7 =P3^7;//E pin connected to pin 4 of port 3

 

void msdelay(unsigned int time)  // Function for creating delay in milliseconds.

{

unsigned i,j ;

for(i=0;i<time;i++)

for(j=0;j<1275;j++);

}

void lcd_cmd(unsigned char command)  //Function to send command instruction to LCD

{

display_port = command;

rs= 0;

rw=0;

e=1;

msdelay(1);

e=0;

}

void lcd_data(unsigned char disp_data)  //Function to send display data to LCD

{

display_port = disp_data;

rs= 1;

rw=0;

e=1;

msdelay(1);

e=0;

}

void lcd_init() //Function to prepare the LCD  and get it ready

{

lcd_cmd(0x38);  // for using 2 lines and 5X7 matrix of LCD

msdelay(10);

lcd_cmd(0x0F);  // turn display ON, cursor blinking

msdelay(10);

lcd_cmd(0x01);  //clear screen

msdelay(10);

lcd_cmd(0x81);  // bring cursor to position 1 of line 1

msdelay(10);

}

void main()

{

unsigned char a[15]=”KEVIN MATHEW; //string of 14 characters with a null terminator.

int l=0;

lcd_init();

while(a[l] != ‘\0’) // searching the null terminator in the sentence

{

    lcd_data(a[l]);

    l++;

    msdelay(50);

}

}

Click here to see the video of LCD Interfacing with 8051 Microcontroller