An Elegant Keypad, Extendable to Keyboard
by yubingnz in Circuits > Arduino
32 Views, 1 Favorites, 0 Comments
An Elegant Keypad, Extendable to Keyboard
As promised in my last instructable, this keypad is easier to configure, as well as to code. And it is scalable to a MxM matrix to serve M*(M-1) keys, using only M IOs to interface microcontroller. It is extendable to a full-fledged computer keyboard. For a standalone desktop keyboard, the keyboard decoder needs to be reengineered with less IOs, as less as half, by extra diodes to form a loop from columns to rows, one to one.
Supplies
Keypad: You can use any 4x3 keypad salvaged from unused electronics, providing it's easy to trace the PCB layout to cut and soldering. Or you can use 12 push buttons to build your own.
Diode: 4 pcs at least for 4x3 keypad, a general purpose 1N4148 should work. I desoldered them from junk PCB.
Display: Optional if you are comfortable with the IDE serial monitor to check keypress. I'm using an I2C LCD for a standalone demonstration rather than EM32110 series in my last instructable. You can use any other display as long as you know how to work with it.
Arduino Platform: I'm using Arduino UNO R3.
If you have ever tried my last instructable, you can reuse them for this. The difference is it uses less diodes.
Configure Your Keypad
If you want to build your own with 12 push buttons, just follow the schematics.
If you have a keypad like mine, you had to transform the 4x3 keypad to 4x4 one against the schematics. Use your PCB tracing skill, visually or by multimeter to test the connectivity.
There's no PCB work for the rows, but the columns. Use cutter and soldering tool to regroup the original three columns to four. Use small drill bit to drill the PCB for diodes and jumper wire installation. Use your pen to make the holes as R1 - R4, and C3 to C4.
Remove the soldering mask at the spot where diodes and jumpers are supposed to be soldered. Use the four diodes to build the four loops from column (Anode) to row (cathode), respectively. To retain rubber performance, all diodes and jumper wires must on the component side, while soldering spot must be as farther as possible away from the keys.
Double check the connectivity and reassemble the keypad assembly. Make sure R1, R2, R3 and R4 are accessible for soldering later.
Simulation
The simulation uses 40x4 LCD because no Proteus library for my I2C 16x2 one. The serial monitor is enough if you don't have one.
Implementation
Wiring up the keypad and LCD assembly to Arduino by soldering or jump wires. The keypad shown here is wired by jumpers because I want to demonstrate the symmetric characteristics of the keypad by rotation 180 degree, where you can view the video.
The code for simulation can be uploaded directly if the same LCD is used. I had to change the I2C address to 0x27 for my 16x2 LCD before uploading.
About the demo: The first 10 second shows normal keypress in order; the last session demos keypress in reverse order. In between I flipped the 4 IOs to show how fun it is to see a keypad is invertible.
Github repository:
https://github.com/QuteNZ/An-Elegant-Keypad-extendable-to-Keyboard.git
and Demo Video:
https://youtu.be/oLSrkSVk7Mg
The Beauty of the Keypad
Up to now, we have three types of matrix keypad configuration. For discussion purpose, let me call the legacy matrix as standard one, this one and my last instructed one are looped keypads because all columns of the matrix are looped to rows, as shown in the image attached.
Both looped keypads use less IOs for interfacing because the legacy matrix uses one group as output and other as input statically, rows or column. Looped keypads use any IO as both input and output alternatively. To distinguish both types of loops, let me call the first one as Outer Loop Keypad and the second as Inner Loop Keypad.
The Beauty of Simplicity: For a 4x3 loop keypad, there's not much difference in terms of complexity. If the keys are more than 12, loop diodes increase one by each row and column for this Inner Loop keypad, but increase dramatically for Outer Loop keypad. If you look into the code implement on Arduino, a simple algorithm is employed for Inner Loop one rather than the boring lookup table for Outer Loop one.
The Beauty of Scalability: Because of the simplicity mentioned above, a Mx(M-1) keys or less, it is expectable to use M diodes to form MxM matrix, the limitation is the IOs reserved for keypad/keyboard. The application can be extended to large number of keys such as computer keyboard.
The Beauty of Symmetry: The demo shows the keypad works as expected when rotating 180 degrees without changing the code. No other styles of keypad can do it, isn't it?
Fun With TinkerCAD
To my surprise, the simulation works on TinkerCAD. It is great if:
- You have no Proteus installed, and you're comfortable with online application
- You have no keypad available for this make, but you want to build your own on breadboard, or strip board
- You just want to explore the code to make it better.
I'm trying to keep the code in consistency, though minor change is necessary from Proteus to TinkerCAD. For example I had to replace lcd.begin() with lcd.init() to make it work here perhaps both uses different library.
Here's the link to share:
https://www.tinkercad.com/things/a2BjbLtu1YF-elegant-keypad-extendable-to-keyboard