Microcontroller Programming Keypad Decoding Techniques
In the design of electronics project, it is very common to use a keypad matrix as a means for user to interface to the product. In order to minimize the number of pins used in the microcontroller, the keys should be arranged in as square a matrix as possible.
One example is the use of 4 X 4 matrix arrangement in a 16 keys keypad. This arrangement require only 8 pins. If it is arrange in a 2 X 8 matrix, 10 pins will be needed instead of 8. The microcontroller programming keypad decoding method has 4 inputs pins designated as row 1 to row 4 and 4 output pins designated as column 1 to column 4. The 4 input ports need to have a pulldowns resistor to ensure that they are always at a deterministic state either login "0" or login "1".
This is achieved by having an internal pulldown resistor in the MCU itself or by having 4 external resistors connected to each of the input pin and ground.
At the start of the scanning, column 1 will be turned ON(login "1") and column 2, 3, and 4 turn OFF (logic "0"). When this happen, the input ports row 1 to row 4 are scanned for its status. If key 7 is pressed, the pin PA2 at row 3 will return as logic "1" and the rest of the rows will return logic "0".
By having a debouncing routine as a means of confirmation that the particular key has been pressed, the MCU will know which key is pressed and thus is able to proceed to determine the next action to take.
Low Power Consumption Consideration
In the design of key interface, it is also important to choose a MCU that is able to go into power down mode after a certain time has elapsed. This will ensure that the batteries that are used to power up the MCU will last longer. It will only wake up when a key is pressed. Power down mode typically takes a fraction of current compared to when it is in active mode.
oin electronics design contest and win prizes. Test your hardware and software skills against the best designers from the rest of the world.
Join the electronics events to enhance your knowledge and network with other professionals in this industry.
Some engineering free magazine available for you to subscribe today
Explore the use of 7-Segment Display, 555 Timer, Decade Counter and Binary Adder. Get the circuit.
Design and build a battery tester to test dry cell and rechargeable battery with a voltage of less than 2V. Check here.
Construct this simple door bell chime and have fun. Find out more here.
Build this simple home alarm to protect your house from intruders. See the schematic circuit.