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.

matrix keyboard any fresh pic code ?

Status
Not open for further replies.

manish12

Advanced Member level 3
Joined
Nov 21, 2006
Messages
983
Helped
66
Reputation
132
Reaction score
33
Trophy points
1,308
Activity points
6,117
i need the code for matrix keyboard using pic 877 but port pins is not from the same por.

thank you
 

no i need code in asm form

thank you
 

thank you

but , can anybody help me ?
:cry:
 

Perhaps if you provided a schematic showing how you have the 3x3, 3x4, or 4x4 keypad connected and what pins you're using?
 

i am not having the ckt but the arrengment is like this

;RA1-C0
;RA2-C1
;RA3-C2
;RA4-C3

;RA5-R0
;RE0-R2
;RE1-R3
;RE2-R4

;R0-------SW1--------SW2--------SW3---------SW4
; | | | |
;R1-------SW5--------SW6--------SW7---------SW8
; | | | |
;R2-------SW9--------SWA--------SWB---------SWC
; | | | |
;R3-------SWD--------SWE--------SWF---------SW0
; | | | |
; C0 C1 C2 C3


thank you .
 

Hi,
here is a project for keypad lock for electronic door, using 16f84,
but you may easy adapt this for 16f877,
also you have asm code, with very small corection this will be work on 877,
if you have problem mail me, I will help you,
regards
 

thank you .

i am the begener for pic just 1year exp. not so much knlg but i will try to convert it
but still if one have the subrutine for it , that is best option for me.
thank you again
 

;-------------------------------------------
keyread clrf portb
clrf portd

bsf portb,4
btfsc porta,ret1
goto r1c1
btfsc porte,ret2
goto r1c2
btfsc porte,ret3
goto r1c3
btfsc porte,ret4
goto r1c4
bcf portb,4
bsf portb,5
btfsc porta,ret1
goto r2c1
btfsc porte,ret2
goto r2c2
btfsc porte,ret3
goto r2c3
btfsc porte,ret4
goto r2c4
bcf portb,5
bsf portb,6
btfsc porta,ret1
goto r3c1
btfsc porte,ret2
goto r3c2
btfsc porte,ret3
goto r3c3
btfsc porte,ret4
goto r3c4
bcf portb,6
bsf portb,7
btfsc porta,ret1
goto r4c1
btfsc porte,ret2
goto r4c2
btfsc porte,ret3
goto r4c3
btfsc porte,ret4
goto r4c4
bcf portb,7
retlw 00

r1c1 bcf portb,4
movlw 07h
return

r1c2 bcf portb,4
movlw 08h
return

r1c3 bcf portb,4
movlw 09h
return

r1c4 bcf portb,4
movlw 0Ah
return

r2c1 bcf portb,4
movlw 04h
return

r2c2 bcf portb,4
movlw 05h
return

r2c3 bcf portb,4
movlw 06h
return

r2c4 bcf portb,4
movlw 0Bh
return

r3c1 bcf portb,4
movlw 01h
return

r3c2 bcf portb,4
movlw 02h
return

r3c3 bcf portb,4
movlw 03h
return

r3c4 bcf portb,4
movlw 0Ch
return

r4c1 bcf portb,4
movlw 10h
return

r4c2 bcf portb,4
movlw 0Fh
return

r4c3 bcf portb,4
movlw 0Eh
return

r4c4 bcf portb,4
movlw 0Dh
return
will you explain it .

i think you need to diversify....................
 
keyread
bsf portb,4
takes the port line high
btfsc porta,ret1
check to see it a key has been pressed and return line 1 is high
goto r1c1
if so goto row1coloum1 press detected
btfsc porte,ret2
check to see it a key has been pressed and return line 2 is high
goto r1c2
if so goto row1coloum2 press detected
.
.
so on and so forth

r1c1 bcf portb,4
clear the high bit to low
movlw 07h
since row 1 and column 1 value is 7
return
return 7 in W

This code is for 4x4 matrix. For each scan line going high, all 4 returns lines are tested. If the return lines are detected to be high, then the appropriate code is returned.

Cheers

Ravi
 
thank you ,

this is the code , for which i am looking for.

but it is lengthy but quit good.!!!!!!!!
 
manish12 said:
but it is lengthy but quit good.!!!!!!!!
It can be cut down provided the can and return lines are mapped properly.

For example, if the scan lines are PORTB0..3 and return lines are PORTB4.7, then the code can be as follows.

bsf portb,0
movf portb,w
andlw 0F0h ; mask lower nibble
sublw 00 ; check for 1's in upper nibble
btfss status,zero
goto key_detected
no key pressed

Cheers

Ravi
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top