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.
Half of the port pins (P10~P13) are used to strobe the keyboard, that is, you drive with the program these lines LOW one at a time, periodically.
Then, as the line is low, you read the port and see if any of the P14~P17 lines is LOW. If so, then one switch is closed. You determine which one by knowing which line was driven LOW and which input line was found LOW.
For example, if P10 is LOW and you find that P15 is LOW, then switch S5 is closed.
If you have fewer keys, you can use fewer lines. A 12-key keypad for example (phone keys) would need 4x3 lines, so you save one port I/O. It could be important, for example the timer input.
The resistors are not absolutely necessary, but they can speed up the keys.
I have a 3x4 keypad and I have tested it with meter to determine the column and row.
I have found that from first to third pin represents column 1 to 3 while forth to sixth pins are for row 1 to 3. Now I want to interface it with my 8051 chip but How earth can I connect 3 pull-up resistor on columns?
LOOKUP:
MOV R2,A
MOV DPTR,#TABLE
LABEL_1:
CLR A
MOVC A,@A+DPTR
CJNE A,02,LABEL_2
MOV A,DPL
ADD A,#10H
MOV DPL,A
CLR A
MOVC A,@A+DPTR
RET
LABEL_2:
INC DPTR
MOV A,R2
LJMP LABEL_1
TABLE:
DB 0x00,0x04,0x08,0x01,0x05,0x09,0x02,0x06,0x0a,0x03,0x07,0x0b,0x0c,0x00,0x00,0x00,0x0a,0x00,0x0b,0x07,0x08,0x09,0x04,0x05,0x06,0x01,0x02,0x03,0x0c,0x00
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.