8051 LCD Interfacing

By | June 28, 2015

LCD is the abbreviation for Liquid-crystal-display. It can able to display characters, numbers, and special characters. LCD is further sub characterized into two types:

  1. Alpha numeric LCD or Character LCD
  2. Graphical LCD

In this project, let us see the interfacing of a 16×2 alpha numeric LCD with a 8051 microcontroller. Later, I will update the graphical LCD interfacing.

—- TBD —-

 

8051 LCD Interfacing – block diagram

8051 Lcd Interfacing - Block diagram

8051 LCD Interfacing – code

/* 
 * Project : LCD interfacing with 8051 Microcontroller
 * Description : In this project, we will be interfacing 
 *               16x2 LCD with a 8051 microcontroller.
 * Software : Keil uVison4
 * MCU : AT89S51/S52
 * Oscillator : 11.0592 Mhz
 * Date : 11-06-2015
 */   

#include <reg51.h>

sbit rs = P3^2;
sbit rw = P3^3;
sbit en = P3^4;

void delay(int i)
{
	 int j;
 	 for(;i;i--)
	 for(j=122;j;j--);
}

void Data_Lcd (unsigned char Dat)
{
	P1 = Dat;

	rs = 1;
	rw = 0; 

	en = 1;
	delay(100);
	en = 0;
}
void Str_Lcd (unsigned char *Ptr)
{
	while(*Ptr)
	Data_Lcd(*Ptr++);
}

void Cmd_Lcd (unsigned char Cmd)
{
	P1=Cmd;

	rs = 0;
	rw = 0;

	en = 1;
	delay(100);
	en = 0;
}

void Init_Lcd ()
{
	Cmd_Lcd (0x38);
Cmd_Lcd (0x01);
	Cmd_Lcd (0x0e);
	Cmd_Lcd (0x0c);
	Cmd_Lcd (0x80);
}

void main()
{
	Init_Lcd ();
	Str_Lcd ("EmbeddedForU.com");
	while(1);
} 

 

8051 LCD Interfacing – Circuit

 

8051 LCD Interfacing – Circuit

8051 LCD Interfacing – Image

8051 LCD Interfacing – Image

8051 LCD Interfacing – Video

 

One thought on “8051 LCD Interfacing

  1. Hosting

    hi am tring to interface the lcd with 8051 microcontoller. it is showing garbage value can someone please help??

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *