Again, the keypad looks like a refugee from the 1980s – however it serves a purpose. Notice that there are eight connections at the bottom instead of seven – the extra connection is for the extra column of buttons – A~D. This example again came from Futurlec. For this tutorial you will need the data sheet for the pinouts, so download it from here (.pdf).
To use this keypad is very easy, if you haven’t already done so, download the numeric keypad Arduino library from here, copy the “Keypad” folder into your ../arduino-002x/libraries folder, then restart the Arduino IDE.
Now for our first example – just to check all is well. From a hardware perspective you will need:
If you don’t have an LCD – that’s ok. Our demonstration sketch also sends the key presses to the serial monitor. Just delete the lines referring to Wire, LCD etc.
Connect the keypad to the Arduino in the following manner:
Keypad row 1 (pin eight) to Arduino digital 5
Keypad row 2 (pin 1) to Arduino digital 4
Keypad row 3 (pin 2) to Arduino digital 3
Keypad row 4 (pin 4) to Arduino digital 2
Keypad column 1 (pin 3) to Arduino digital 9
Keypad column 2 (pin 5) to Arduino digital 8
Keypad column 3 (pin 6) to Arduino digital 7
Keypad column 4 (pin 7) to Arduino digital 6
Now for the sketch – take note how we have accommodated for the larger numeric keypad:
the extra column in the array char keys[]
the extra pin in the array colPins[]
and the byte COLS = 4.
And our action video:
Now for another example – we will repeat the keypad switch from chapter 42 – but allow the letters into the PIN, and use the LCD instead of LEDs for the status. In the following example, the PIN is 12AD56. Please remember that the functions correctPIN() and incorrectPIN() are example functions for resulting PIN entry – you would replace these with your own requirements, such as turning something on or off:
Now let’s see it in action:
So now you have the ability to use twelve and sixteen-button keypads with your Arduino systems.
Have fun and keep checking into tronixstuff.com. Why not follow things on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other – and we can all learn something.