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.

8051 microcontroller with keypad

Status
Not open for further replies.

eime

Newbie level 3
Joined
Apr 27, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
UAE
Activity points
1,359
Hi all members ;

Actually, I am doing my project the 8051 microcontroller with keypad(4*4) as SMS system using assemply language ......
Can any one help me with samilar code .... I confuse a lot specially when the icon press one time it should dispaly first element pressing twice display the second element and so on .....

Can I have any help ???????????

Thank you

Have a Nice Day
 

Here is a code that I posted some time ago on how to connect a 4 x 4 keypad with 8051 microcontroller:

It may need some modifications to fit into your application, but it is a good starting point ..

IanP
:D
 

Hi all,

Thank a lot IanP for your help .....
I want to ask you if you don't mind ....

The code should take the input from keypad and the output will be dispaly on the screen ....
I have a code which take for one pressing only so, how I can do it for using lookup table with multiple pressing ....... I am confusing with counters and delays

Can you see the code please and try to hep me if you don't mind ...
Thank you a lot ...
eime
The Code :
ORG 8100H ;Start location ....
MOV SP,#5FH ;Stack Pointer ....

MOV A, #10011001B ;Load the A=99H as output port(B)....
MOV DPTR,#0FF43H ;Control Register for the 8051 ....
MOVX @DPTR,A ;Move the value in A to data pointer ....


AGAIN: MOV A,#00001110B ;First row that we will check on it which digit is ON ....
MOV DPTR,#0FF41H ;Port B as output PORT ....
MOVX @DPTR,A

MOV DPTR,#0FF42H ;Port C as input PORT ....
MOVX A,@DPTR ;Move the value in A to data pointer ....
ANL A,#07H ;Anded the value which in A with 07H to get the first three bits ....

CJNE A,#6,OTHER ;Comparing the value in A with 6 if it isn't equal jump to other ....
MOV A,#'1' ;When the value in the A equal with 6 display Char '1' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 1 ....

OTHER: CJNE A,#5,L ;Comparing the value in A with 5 if it isn't equal jump to L ....
MOV A,#'2' ;When the value in the A equal with 5 display Char '2' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 2 ....

L: CJNE A,#3,N ;Comparing the value in A with 3 if it isn't equal jump to N is instead for the second row ....
MOV A,#'3' ;When the value in the A equal with 3 display Char '3' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 3 ....

N: MOV A,#00001101B ;Second row that we will check on it which digit is ON ....
MOV DPTR,#0FF41H ;Port B as output PORT ....
MOVX @DPTR,A

MOV DPTR,#0FF42H ;Port C as input PORT ....
MOVX A,@DPTR ;Move the value in A to data pointer ....
ANL A,#07H ;Anded the value which in A with 07H to get the first three bits ....

CJNE A,#6,OTHER1 ;Comparing the value in A with 6 if it isn't equal jump to other1 ....
MOV A,#'4' ;When the value in the A equal with 6 display Char '4' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 4 ....

OTHER1: CJNE A,#5,L1 ;Comparing the value in A with 5 if it isn't equal jump to L1 ....
MOV A,#'5' ;When the value in the A equal with 5 display Char '5' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 5 ....

L1: CJNE A,#3,N1 ;Comparing the value in A with 3 if it isn't equal jump to N1 is instead for the third row ....
MOV A,#'6' ;When the value in the A equal with 3 display Char '6' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 6 ....

N1: MOV A,#00001011B ;Third row that we will check on it which digit is ON ....
MOV DPTR,#0FF41H ;Port B as output PORT ....
MOVX @DPTR,A

MOV DPTR,#0FF42H ;Port C as input PORT ....
MOVX A,@DPTR ;Move the value in A to data pointer ....
ANL A,#07H ;Anded the value which in A with 07H to get the first three bits ....

CJNE A,#6,OTHER2 ;Comparing the value in A with 6 if it isn't equal jump to other2 ....
MOV A,#'7' ;When the value in the A equal with 6 display Char '7' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 7 ....

OTHER2: CJNE A,#5,L2 ;Comparing the value in A with 5 if it isn't equal jump to L2 ....
MOV A,#'8' ;When the value in the A equal with 5 display Char '8' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 8 ....

L2: CJNE A,#3,N2 ;Comparing the value in A with 3 if it isn't equal jump to N2 is instead for the forth row ....
MOV A,#'9' ;When the value in the A equal with 3 display Char '9' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 9 ....


N2: MOV A,#00000111B ;Forth row that we will check on it which digit is ON ....
MOV DPTR,#0FF41H ;Port B as output PORT ....
MOVX @DPTR,A

MOV DPTR,#0FF42H ;Port C as input PORT ....
MOVX A,@DPTR ;Move the value in A to data pointer ....
ANL A,#07H ;Anded the value which in A with 07H to get the first three bits ....

CJNE A,#6,OTHER3 ;Comparing the value in A with 6 if it isn't equal jump to other3 ....
MOV A,#'X' ;When the value in the A equal with 6 display Char 'X' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character X ....

OTHER3: CJNE A,#5,L3 ;Comparing the value in A with 5 if it isn't equal jump to L3 ....
MOV A,#'0' ;When the value in the A equal with 5 display Char '0' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
JMP AGAIN ;Jump to the main program after Displaying the character 0 ....

L3: CJNE A,#3,N3 ;Comparing the value in A with 3 if it isn't equal jump to N3 ....
MOV A,#'#' ;When the value in the A equal with 3 display Char '#' ....
LCALL 0093H ;Location for the Displaying on the PC monitor ....
CALL DELAY ;Call the Delay block ....
N3: JMP AGAIN ;Jump to the main program after Displaying the character # ....

;##############################################################################################
;############################################# Delay Block ####################################
;##############################################################################################

DELAY: MOV R5,#4H ;DELAY FOR 0.5 SECOND ....
L31: MOV R6,#0FFH
L21: MOV R7,#0FFH
L11: DJNZ R7,L11
DJNZ R6,L21
DJNZ R5,L31
RET


ORG 9000H
LUP1: DB 'A','B','C'
LUP2: DB 'D','E','F'

END ;End the program ....
 

Code:
MOV A, #10011001B ;Load the A=99H as output port(B).... 
MOV DPTR,#0FF43H ;Control Register for the 8051 .... 
MOVX @DPTR,A ;Move the value in A to data pointer .... 


AGAIN: MOV A,#00001110B ;First row that we will check on it which digit is ON .... 
MOV DPTR,#0FF41H ;Port B as output PORT .... 
MOVX @DPTR,A 

MOV DPTR,#0FF42H ;Port C as input PORT .... 
MOVX A,@DPTR ;Move the value in A to data pointer .... 
ANL A,#07H ;Anded the value which in A with 07H to get the first three bits ....

This code is written for 8255 PIA, do you want to use 40-pin input/output device to read 4x4 keypad?
It can be easily done with one of 8051's ports (all together 8 pins) ..

If you want to use it, however, you have to describe your hardware in detail, as writing codes for unknown hardware configuration doesn't make sense ..

IanP
:|
 

Hi all ;

How are you IanP ?? Hoping you are fine ....

I am using FLT_32 microcontroller trainer is based on the Intel's MCS-8032/51..
The project should submit by using this trainer .... I can't use 8051 40Pins ...

IanP what I should do now ???

Thank you a lot IanP
Have a Nice Day :D
 

From what I see, this code reads input and compares input with certain numbers and outputs 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, X and # .. and the operation can be repeated every 0.5s, as that’s the delay which is inserted after a number is sent out ..
So far, have you run it, does it work that way, or what’s the problem?

There is no reference in the code to tables located at 9000h, so it looks like they can be omitted ..

IanP
:|
 

Hi all,

IanP you are right about what you said .....

I want know to add this code IN WAY TO MAKE IT WORK AS SMS MOBILE ...
SO when I press icon 2 one time it must display 'A' and if I am pressing the same icon twice it must display 'B' and so on ....

MOV R1,#00H;AS COUNTER
READ:MOV DPTR,#LUP1
MOVX A,@DPTR
LCALL 0093H
CALL DELAY
INC R1
INC DPTR
JMP READ
ORG 9000H
LUP1: DB 'A','B','C','2'

IanP what do you think how I should do it :cry:??????

Thank you IanP
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top