Introduction: 4x4 Keypad With Arduino and Processing

Don't like LCD displays??

Want to make your projects look appealing?

Well, here is the solution. In this Instructable you'll be able to free yourself from the hassles of using an LCD screen to display content from your Arduino and also make your projects look good with this amazing and free GUI software called Processing. By the end of this project you'll be able to interface different types of keypads with Arduino and be familiar with Processing.

What can you do with this?

  • Interface 4x4 keypad with arduino.
  • Create graphical interfaces of your choice

What you will learn from this

  • Interfacing any keypad with Arduino
  • Processing software.
  • Communication between Processing and Arduino.

Step 1: Parts Required

You'll require the following parts for this project:

  1. Arduino (any Arduino will do).
  2. Keypad (it can be 4x4 or 4x3. I have used a 4x4 keypad).
  3. Processing Software.
  4. Keypad library

Here are the links if you don't have the software.

Arduino IDE

Processing

Extract the zip and move it to the libraries folder in Arduino. After doing that, you should be able to see some example sketches in the Arduino IDE.

Step 2: Working

Now let's first understand how the keypad functions.

The keypad works on the simple principle of a switch i.e the circuit is complete when the switch is pressed.

We assign the row pins with a HIGH or VCC and the column pins with a LOW or GND. This can be done with the help of GPIO pins on Arduino. Then we keep checking the column pins for a change in input.

Suppose we press 1 on the keypad, then according to the diagram it's located at r1,c1. Therefore if we give HIGH to row1 then the column1 will read a HIGH on the pin. This is how we will be able to find out which key is pressed. Since only row1 is given HIGH, we can be 100% sure that r1,c1 is pressed. This is how you can map all the keys.

If you want further explanation or this wasn't enough, there are ample number of videos on youtube which explain the working of a simple keypad. You can watch them if you want.

Step 3: Processing

So now lets start with the GUI part. For this we will use a software called Processing. I have provided the link in Step 1.

This is basically where we will visualize our output from the Arduino. The first image is what the keypad looks like from the code that follows it. Once you are familiar with Processing you can make your own keypad.

Now to explain the code. It's pretty much easy as the explanation for all the functions can be found on the Processing site.

In the second picture you can see that I have setup all the necessary libraries and in the void setup() I have initialized the window, the text font and the serial port.

The third picture is where I have actually made the keypad, adding all the keys, the squares, display, etc.

Fourth picture has the conditions for when we receive an input through the serial connection. Basically I make the keys flicker so as to give an appearance that the key is being pressed.

Last picture is where the serial event is taking place and this is where we are getting our input.

Step 4: Connections, Arduino Code and Explanation

To make the connections hold the keypad with the keys facing you. From the left it goes like this R0,R1,R2....

R0 ----> pin 2

R1-----> pin 3

R2-----> pin 4

R3-----> pin 5

C0-----> pin 6

C1-----> pin 7

C2-----> pin 8

C3-----> pin 9

Now let us look at the Arduino code. It's nothing out of the ordinary. As usual in void setup() you start the serial communication with 9600 as the baud rate. Then in void loop() I have used a variable to get and store the value from the keypad. This value I send through the serial port with a full stop after it so that it becomes easy to identify the end of the data in Processing. We do this so that the serial port does not keep searching for the end of the data. In Processing we use the statement buffer until it sees the full stop. In the following video I have given a detailed explanation of the process.

Well that's it. Extract all the files, make the connections and enjoy.

Thank you.

Comments

author
gomibakou (author)2017-06-26

What about the "ghosting" and "masking"? these are usual problems to count when using matrix keypads. Some diodes (check any good source about ghosting or masking) could help.

author
Chinmay17 (author)gomibakou2017-06-26

I will surely look into it

author
gomibakou (author)Chinmay172017-06-28

It took some time to find the link again, but I think this is the best explanation about masking and ghosting I found, simple and simple:

http://www.dribin.org/dave/keyboard/one_html/

Anyway it's also possible to reduce or even eliminate some of these effects using software, but it's not trivial.

author
Swansong (author)2017-06-26

That looks neat :) I'd like to put one of these on the door to the garage.

author
Chinmay17 (author)Swansong2017-06-26

Thank you so much:)

About This Instructable

788views

26favorites

License:

Bio: 4th year Electronics student. Huge passion for electronics and DIY projects. Interested in medical electronics and automotive.
More by Chinmay17:4x4 Keypad With Arduino and Processing
Add instructable to: