View Single Post
Old Apr 17th, 2006, 6:58 PM   #1
hbe02
Hobbyist Programmer
 
hbe02's Avatar
 
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3 hbe02 is on a distinguished road
PIC16F84 & KEYPAD

so im wrote the assembly code for an electronic lock door opener which takes a 3 digit input form a keypad, displays the input on a LED and then through an FSM if the correct 3 digit passcode is entered followed by a # a signal will be sent on portA(4) to open a relay. i also optimized my code for accepting a change of pass word. for example if the passcode is 000 and you want to change it to 111. you type "000*111*111#" .. alright now the code is complete and tested and all works. but as it is too late to enquire about this now... i want to make sure that how i think the keypad works on processors is corerct.
i know that a 4x4 keypad is a 2D array of switches, so 4 have 4 inputs which are the rows from the pic to the keypad and 4 outputs from the keypad to the pic. i assumed on my own that i could set each row to one then zero in sequential order and have an interrupt if any of the columns gives a one. thing is , i kind of came up with this on my own and im not sure it works on hardware. here's what my main looks like... so does this work??
MAIN
			BCF		PORTB,3

			BSF		PORTB,0
			BCF		PORTB,0

			BSF		PORTB,1
			BCF		PORTB,1

			BSF		PORTB,2
			BCF		PORTB,2

			BSF		PORTB,3

			GOTO	MAIN
portB from 0 to 3 are inputs to the keypad ... and once a key is pressed, the corresponding switch will close and the corresponding column will give an interupt (portB(4) - portB(7) ...
i assumed that delay of setting and clearing would be too small to the human hand so the interrupt will be generated correctly...
thanks for the help...
ow btw .. if you want to take a look at my code its in the reply below this..
hbe02 is offline   Reply With Quote