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 password system

Status
Not open for further replies.

rajrahul2391

Junior Member level 1
Joined
May 22, 2013
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,404
hello friends,
i m working on 2*2 matrix keyboard system ,in which a password is to be set to open a door (device).can any body suggest me a simple code for that.
thanks in advance .
 

hi,
for interfacing 2 * 2 matrix keypad(4 switch) you require 4 IO lines. so you can connect each switch in each line and read the status of that line
 

that's right sir but i could be able to put password correctly plz give me direction by suitable code.....
 

Which microcontroller you are using?
 

The tutorial in assembler.
Interfacing hex keypad to 8051
You can use three keys for serial input password and a single key to confirm your entry, as this code does not handle simultaneous key press.
 

If you detect the key which is press then then take single bit to enable password function if this function is enable then when u will press any key put it any buffer like password[count] = key_press_number;
and increase the count after key press in password function.
 
Code:
/*------------------------------------------------
Keyboard 4*4 read
P1.7 ->-R3----------------F\|-E\|-D\|-C\|
P1.6 ->-R2----------------B\|-A\|-9\|-8\|
P1.5 ->-R1----------------7\|-6\|-5\|-4\|
P1.4 ->-R0----------------3\|-2\|-1\|-\0|
P1.3 -<-C3------------------|   |   |   |
P1.2 -<-C2----------------------|   |   |
P1.1 -<-C1--------------------------|   |
P1.0 -<-C0------------------------------|

keypressed = (1)	0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
                        0-Low                             15-High
Interrupt routine for 0 Low level needs.
------------------------------------------------*/
sfr P1 = 0x90;          /* SFR definition for Port 1 */
sfr P3 = 0xB0;          /* SFR definition for Port 3 */

#define  MASK  0x0F /*  low nibble mask 00001111 Setup P1 for Input P1.0-P1.3 Output P1.4-P1.7   */


/*------------------------------------------------
MAIN C Function
------------------------------------------------*/
void main (void)
{

unsigned int keypressed;     /* variable for key values */

	P1 = MASK;              	/* Setup P1 for Input P1.0-P1.3 Output P1.4-P1.7   */

/*--------------------------------------
Use the Toolbox buttons in the debugger
to change the value of P1.0-P1.3. 
--------------------------------------*/
while (1)
  {
		char row,runbit,pval; /* temp variable for port values */

 		for (row=0, runbit=0x10; row<4; row++) 
 		{
 			P1 = ~runbit|MASK;			   /*Output P1.4-P1.7  running 0 */
			pval = ~P1&MASK;           		   /* Read Input P1.0-P1.3 into pval -- 1 is pressed key*/
			keypressed = pval|keypressed<<4;  /* Pack pressed key in to keypressed */
 			runbit <<= 1;
		}
	}
}
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top