Tutorial: Arduino and Numeric Keypads – Part Two

Use larger numeric keypads in this addendum to chapter forty-two of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – a series of articles on the Arduino universe. The first chapter is here, the complete series is detailed here. Any files from tutorials will be found here.

Welcome back fellow arduidans!

This is the second part of our numeric keypad tutorial – in which we use the larger keypads with four rows of four buttons. For example:

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:

  • An Arduino Uno or 100% compatible board
  • A 4×4 numeric keypad
  • An LCD of some sort. We will be using an I2C-interface model. If you are unsure about LCD usage, please see this tutorial
  • 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.

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, 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.

The following two tabs change content below.

John Boxall

Founder, owner and managing editor of tronixstuff.com.

2 Responses to “Tutorial: Arduino and Numeric Keypads – Part Two”

  1. Kati Calamia says:

    Ameeeeei este website, muito agradável.

    Congratulações!!! Prossiga escrevendo outras vezes!

    Felicidades!

  2. samuel kipruto says:

    am trying to write a program to lock a door using a pin code. i have tried your program but i cant upload to my arduino as it cant be verified/compiled. am using arduino duemilanove

Trackbacks/Pingbacks


Leave a Reply

Receive notifications of new posts by email.

Arduino Tutorials

The Arduino Book

Arduino Workshop

Für unsere deutschen Freunde

Dla naszych polskich przyjaciół ...

Australian Electronics!

Buy and support Silicon Chip - Australia's only Electronics Magazine.

Use of our content…

%d bloggers like this: