Working of Keypad and its interfacing with 8051 microcontroller
Keypad is the combination of buttons which is used for more options using less number of pins (wires). Such keypads are used in mobiles for typing SMS or dialing number.
In all of above keypads you have seen there, number of buttons are greater than the number of pins.
In keypad the knowledge of detecting pressed key is important. In example suppose mobile phone keypad the first row is connected to pin A and every button is connected with different pin 1,2&3 .
Suppose we are detecting the button from row1. For this we have to make pin A LOW and pin 1,2&3 HIGH then continuously monitor the pins 1,2&3 that which pin show LOW, if pin 1 show low it means digit 1 is pressed, if pin 2 shows LOW it means digit 2 is pressed and if pin 3 shows LOW it means digit 3 is pressed. Same procedure for all rows in keypad. There also possibility that may be LOW is due to noise. So when button pressed is detected then with small interval confirm that button again.
Interfacing with microcontroller:
Let’s interface keypad with microcontroller and shows its button pressed on 7-segment.
Have a look on circuit.
In this circuit common anode 7-segment is used to display the digit which will pressed on keypad. By using this technique, we can interface any keypad with microcontrollers.
Check the commented c language code of this circuit.
Thanks.
This article was prepared for you by Hafiz Abdul Haseeb Tariq from FAST-National University of Computer and Emerging Sciences-Pakistan. He’s an Electronics & Embedded system engineer and has practical experience in circuit designing, networking, assembling, PCB making, 8051 & Arduino programming.
You can check out his previous article in the below link:
https://www.electronicsrepairfaq.com/door-security-lock-with-keypad
Something new to learn! Good! Thanks!
Can u plzz let us know the procedure to interface keypad and speaker simultaneously with microcontroller 8051 or arduino
Hafiz,
Thanks for sharing programming information.
Thanks for this informative article Hafiz Abdul Haseeb Tariq. C language programming looks very easy but after learning BASIC, PASCAL and a bit of JAVA, to me is harder to learn. I therefore prefer the old programming languages like BASCOM-AVR (BASIC COMpiler), or the new fast coding Flowcode from Matrix Multimedia (with the easy E-Blocks hardware electronic modules which are great for electronics engineers who want to design a system in a very short time!), and a bit in VHDL (which is unlike any other previous language a Parallel programming language). And in line with your present article on keypad interfacing, it in BASCOM is even possible to easily program a telephone generating DTF (Dual-Tone-Frequency) keypad that can be used on our modern telephone lines to call someone anywhere in the world. (The DTF code is already integrated into the BASCOM-AVR language. But there also is a BASCOM-8051 compiler version. All free usable upto 2k code).