Skip to main content

How to interface 16x2 lcd with AT89C51 to display text, numeric and special character

hi, how are you today



Let's learn how to interface a LCD with our baby (8051uC)

Description

This article helps you to understand the concept behind the interfacing
of 16x2 lcd with at89c51. In todays automation its mandatory to keep your eyes on each
and every information totrack each and every single detail and weather its a washing
machine, printer, ticket machine etc. and this is only possible to display on small
module called LCD(Liquid Crystal Display). There is no limitation like on 7-segment,
here you can display number, character or special symbols etc .

16x2 means it acn display 16 values in single line and there are 2 such lines. Here
each value is displayed on 5x7 dot matrix.

Working of LCD is basically depends on the 2 registers.
COMMAND Register: This register stores the value of command that help LCD to do
some specific predefined instruction like initialization, cursor behaviour/position
etc.
DATA Register: This register stores the data value that has to be display on LCD.
The data is the ASCII value of the character, number, special char.

Here we learn how to display number, character and special symbol on 16x2 lcd.

 Programming

1:  #include<reg51.h>      // header file  
2:  void delay(int time)    // function to generate delay  
3:     {  
4:     int i,j;  
5:     for(i=0;i<=time;i++)  
6:     for(j=0;j<=1275;j++);  
7:     }  
8:  sbit RS=P2^5;  
9:  sbit RW=P2^6;  
10:  sbit EN=P2^7;  
11:  void command(unsigned char m) // function to generate command  
12:     {  
13:     P3=m;  
14:     EN=1;  
15:     RS=0;  
16:     RW=0;  
17:     delay(10);  
18:     EN=0;  
19:     }  
20:  void ldata(unsigned char m)   // function to generate data  
21:     {  
22:     P3=m;  
23:     EN=1;  
24:     RS=1;  
25:     RW=0;  
26:     delay(10);  
27:     EN=0;  
28:     }  
29:  void main()         // main function  
30:     {  
31:      while(1)  
32:       {  
33:        command(0x38); delay(10);  
34:        command(0x0E); delay(10);  
35:        command(0x01); delay(10);  
36:        command(0x06); delay(10);  
37:        command(0x80); delay(10);  
38:        ldata('E');   delay(10);  
39:        ldata('r');   delay(10);  
40:        ldata(' ');   delay(10);  
41:        ldata('M');   delay(10);  
42:        ldata('S');   delay(10);  
43:        ldata('D');   delay(10);  
44:        command(0xc6); delay(10);  
45:        ldata('S');   delay(10);  
46:        ldata('A');   delay(10);  
47:        ldata('L');   delay(10);  
48:        ldata('A');   delay(10);  
49:        ldata('H');   delay(10);  
50:        ldata('@');   delay(10);  
51:        ldata('1');   delay(10);  
52:        ldata('2');   delay(10);  
53:        ldata('3');   delay(100);  
54:       }  
55:     }   

For enhance concept just visit www.salahtutorials.com
Hope you all like this post and I wish this must be useful for you.
Thanks :)

Comments

Translate to your language

Popular posts from this blog

Different Stages of I2C communication

Different Stages Of I2C

How to import Pygame in pycharm

hi, how are you today

Working demonstration of UART communication using 2 8051 uController on Proteus with Embedded C code.

Here we are going to use 2 at89c51 uControllers just to understand UART communication in 8051.