Please update your Flash Player to view content.

                  FOLLOW  US





 
 
LCD INTERFACING TO 8051 IN 8 BIT MODE
Code Library - C Code Library
Written by Amol Shah   

Liquid Crystal Display also called as LCD is very helpful in providing user interface as well as for debugging purpose. The most common type of LCD controller is HITACHI 44780 which provides a simple interface between the controller & an LCD. These LCD's are very simple to interface with the controller as well as are cost effective.The LCD requires 3 control lines (RS, R/W & EN) & 8 (or 4) data lines.

The number on data lines depends on the mode of operation. If operated in 8-bit mode then 8 data lines plus 3 control lines i.e. total 11 port pins are required. In case of 4-bit mode only 4 data lines are required & the 8-bit data is sent by first sending the higher nibble followed by the lower nibble.

The three control lines are RS, RW & Enable.


RS : Register Select. When RS = 0 the command register is selected. When RS=1 the data register is selected.

RW : Read or Write. When RW=0 write to LCD. When RW=1 read from LCD.

Enable : Used to Latch data into the LCD. A HIGH TO LOW edge latches the data into the LCD.

 


 

Here is a Code in C for interfacing LCD in 8-bit mode.


.

---

.

#define rs                                           P2_5

#define rw                                          P2_6

#define enable                                                 P2_7

#define lcd_port                              P0

main()

{

                Lcd_Ini();

                lcd_command(0x86);

                lcd_display(‘D’);

                lcd_display(‘N’);

                lcd_display(‘A’);

                lcd_command(0x0C4);

                lcd_display(‘T’);

                lcd_display(‘E’);

                lcd_display(‘C’);

                lcd_display(‘H’);

                lcd_display(‘N’);

                lcd_display(‘O’);

                lcd_display(‘L’);

                lcd_display(‘O’);

                lcd_display(‘G’);

                lcd_display(‘Y’);               

                while(1)

                {

 

                }             

}

   

void Lcd_Ini()

{

                lcd_command(0x38);

                delay_ms(30);

                lcd_command(0x0c);

                delay_ms(10);

                lcd_command(0x06);

                delay_ms(10);

                lcd_command(0x01);                    

                delay_ms(10);

}

  

void lcd_command(unsigned char command)

{

                rw=LOW;

                rs=LOW;

                lcd_port=command;

                enable=HIGH;

                enable=LOW;

                delay_ms(5);

}

  

void lcd_display(unsigned char display)

{

                 rw=LOW;

                rs=HIGH;

                lcd_port=display;

 enable=HIGH;

                enable=LOW;

                delay_ms(1);

}


 


 

This program displays “DNA” on first line of LCD and “Technology” on second line.

For delay functions check this link.


 

Comments  

 
-1 # selva 2011-09-22 18:12
i need code for 4*4keypad with lcd interfaced with 8051 using 'c' language and also the keypad row and column must share tha same port...
i mean,if port1 is considered the row must take the first four bits of port1 and the other four bits by the column.... it is urgent.... code must be in only 'c' and no assembly...
Reply | Reply with quote | Quote
 

Add comment


Security code
Refresh

 

Featured Products

Rs1 800.00

 

Random Products

Rs120.00









Rs75.00



Latest Video

Random Articles

Search Products

User Login






 
 
.
 TUTORIALS
.
  8051 Tutorial
 
  Power Supply
 
CODE LIBRARY
.

  8051 Assembly
 
  C Code Library

.
 PROJECTS
.
  Project List
 
  Synopsis and Abstract
 
DOWNLOADS
.

  Datasheets
 
  Download

.
 POPULAR
.
  About Us
 
  DNA Shop
 
  Totorial
 
  Code Library
 
  Download
 

.
 CONTACT US
.

Mr. Amol Shah

DNA Technology Nashik,

Maharashtra 422009 India

Phone : 0253-3023939

Mobile : 09225145135

Email : contact@dnatechindia.com