Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Keypad and LCD interfacing for 8051

Status
Not open for further replies.

ramya.d

Newbie level 6
Newbie level 6
Joined
Apr 9, 2008
Messages
13
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Activity points
1,380
keypad interfacing with 8051

hi everyone,

i am using 8051 f060 kit for my project.
i have to interface keypad and LCD.
can anyone help me out with example programs .
as i am new to this i have no idea of interfacing keypad.
if anyone has any keypad interfacing examples pls help me out.
regards
ramya
 

8051 keypad

please read the "8051 microcontroller and Embedded system by mazidi"
 

lcd interfacing 8051 microcontroller

Hi ramya;

Here is the code. please modify the code as per your port pins configuration on the hardware.

regards
shivaram
 

Attachments

  • lcd_1837.doc
    497 bytes · Views: 418
keypad interface with 8051

hi ,
thanks a lot
 
  • Like
Reactions: musaab

    musaab

    Points: 2
    Helpful Answer Positive Rating
keypad interfacing 8051

Hi,
please let me know what type of LCD you have to use (i.e., LCD Size and 8 bit or 4 bit). i will give u solution.

Regards,
Anand.A
 

can v interface 2 LCDs on same AT89c52 at different ports...?
if yes where should v connect the RS,RW and Enable pins of LCD...??

Added after 33 minutes:

can u tell me how can v get data floating from rt to left in a LCD display..??
 
You don't need different ports to interface 2 LCDs. You can have DB0-DB7, RS, RW pins common. Only EN pins of each LCD will go to different pins on the microcontroller.

What do you means by floating from right to left? You mean scrolling ?
 

yes i mean scrolling..
and 2 LCDs are used to display different datas..
i already have one LCD connected to my port 3.. where do i connect other port 0 is vacant..
sorry i didnt understand your previous reply about shorting..
 

This is what I meant. Since the EN pins are on different port pins, you can display different data on the 2 LCDs.

Code:
+---------------+
|               |                     +--------------------------------------------+
|               |                     |                                            |
|               |-----------------o-->|                                            |
|               |     DB0-DB7     |   |                                            |
|               |--------------o--|-->|                                            |
|               |              |  |   |                   LCD 1                    |
|               |--o----RS-----|--|-->|                                            |
|               |--|-o--R/W----|--|-->|                                            |
|               |  | |         |  |   |                                            |
|               |--|-|--EN-----|--|-->|                                            |
|               |  | |         |  |   |                                            |
|               |  | |         |  |   +--------------------------------------------+
|     89c51     |  | |         |  |
|               |  | |         |  |   +--------------------------------------------+
|               |  | |         |  |   |                                            |
|               |  | |         |  +-->|                                            |
|               |  | |         |      |                                            |
|               |  | |         +----->|                                            |
|               |  | |                |                  LCD 2                     |
|               |  +-|--RS----------->|                                            |
|               |    +--R/W---------->|                                            |
|               |                     |                                            |
|               |-------EN----------->|                                            |
|               |                     |                                            |
|               |                     +--------------------------------------------+
+---------------+

For scrolling, there are examples on the internet. I don't have the code handy right now. If I find it I'll post it here.
 
yes sir.. i have under stood your point of view.. but v can interface any number of LCDs using an 8255 PPI..
what do u think about it..??
 

It doesn't make sense using a port expander chip if you already have enough unused pins on your microcontroller.
Also 8255 is a very old obsolete chip. If you really want to use IO expander, search for new ones.
 

Just refer to the 8051 Micro controller book by Mazidi. Its all in there. As well as there are plenty of examples on the net and plenty posted in this thread only. One part of my last semester project was temperature monitoring and user interfaces on it were of LCD and keypad. I only referred mazidi for that part and I was through.
 
This is john..
Hi guys... Here I tried 4x3 matrix key pad interfacing with 8051 and its working... I have used port 3 and connected row 0, 1, 2, 3 in P3.4, P3.5, P3.6, P3.7 and column 0, 1, 2 in P3.2, P3.1, P3.0 respectively.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include <REGX51.H>
sfr keypad = 0xB0; //port 3
sfr lcd_output = 0x90; //port 1
sbit RS = 0xA0; //port 2.0
sbit RW = 0xA1; //port 2.1
sbit EN = 0xA2; //port 2.2
 
void delay(unsigned int value){
    unsigned int i, j;
    for(i=0;i<=value;i++){
        for(j=0;j<=1000;j++){
        }
    }
}
 
void lcd_cmd(unsigned char value){
    lcd_output = value;
    RS = 0;
    RW = 0;
    EN = 1;
    delay(1);
    EN = 0;
    return;
}
 
void lcd_data(unsigned char value){
    static int a =1;
    a++;
    if(a==17){
        a=1;
        lcd_cmd(0x01);
    }
    lcd_output = value;
    RS = 1;
    RW = 0;
    EN = 1;
    delay(1);
    EN = 0;
    return;
}
 
void lcd_init(){
    lcd_cmd(0x38);
    lcd_cmd(0x0C);
    lcd_cmd(0x80);
}
 
void main(){
    unsigned char arr[4][3] = {'1','2','3',
                               '4','5','6',
                               '7','8','9',
                               '*','0','#'};
    unsigned int row, col;
    lcd_init();
    while(1){
        keypad=0xF0;
        while(keypad != 0xF0); //check for key not pressed
        while(keypad==0xF0); //check for key pressed
        if(keypad==0xE0){ //check for row 0
            row = 0;
            keypad=0xFF;
            keypad=0xEF;
            if(keypad==0xEB)
                col = 0;
            if(keypad==0xED)
                col = 1;
            if(keypad==0xEE)
                col = 2;
            lcd_data(arr[row][col]);
        }
        else if(keypad==0xD0){ //check for row 1
            row = 1;
            keypad=0xFF;
            keypad=0xDF;
            if(keypad==0xDB)
                col = 0;
            if(keypad==0xDD)
                col = 1;
            if(keypad==0xDE)
                col = 2;
            lcd_data(arr[row][col]);
        }
        else if(keypad==0xB0){ //check for row 2
            row = 2;
            keypad=0xFF;
            keypad=0xBF;
            if(keypad==0xBB)
                col = 0;
            if(keypad==0xBD)
                col = 1;
            if(keypad==0xBE)
                col = 2;
            lcd_data(arr[row][col]);
        }
        else if(keypad==0x70){ //check for row 3
            row = 3;
            keypad=0xFF;
            keypad=0x7F;
            if(keypad==0x7B)
                col = 0;
            if(keypad==0x7D)
                col = 1;
            if(keypad==0x7E)
                col = 2;
            lcd_data(arr[row][col]);        
        }
    }
}

 
Last edited by a moderator:

check this link out for
**broken link removed**
hope this might be useful
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top