how do I interface with a 4x4 keypad/

Hi,

I am new to this Arduino uno R3. Can i check how do i use Arduino connected to a 4x4 keypad?

http://arduino.cc/playground/Main/KeypadTutorial

If suppose i had use the custom keypad program from the examples, is that the full program or there is still some parts need to be admend
as i tried to connect the o/p pin to the port of arduino R3

is that the full program

Not sure what you mean. It is an example of how to use the library. If you could code there is nothing at all difficult about writing a function to scan the keyboard and return a key press.

as i tried to connect the o/p pin to the port of arduino

Not sure what you are trying to do.

Sorry, I mean if suppose i am trying to program to use the 4x4 keypad(For example using the 4x4 keypad to the Serial monitor from the arduino software) , what are the necessary connection from the arduino boards to the 4x4 keypad.
Then with the function, how do I program to use it.
As from the link, I don understand as It does not show some program examples where I can try with.

I don understand as It does not show some program examples where I can try with.

Why do you say that? There is example code on that page. You have a 4X4 keypad and it shows a 4X3 example. Try it and just leave one of your connections out. Later you can add it in when you understand more.

what are the necessary connection from the arduino boards to the 4x4 keypad.

Each column connector and each row connector needs to be connected to an arduino pin, that is it.

I'm sorry , I don understand. For example with the code:

/* @file CustomKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Demonstrates changing the keypad size and key values.
|| #
*/
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'0','1','2','3'},
{'4','5','6','7'},
{'8','9','A','B'},
{'C','D','E','F'}
};
byte rowPins[ROWS] = {3, 2, 1, 0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){
Serial.begin(9600);
}

void loop(){
char customKey = customKeypad.getKey();

if (customKey != NO_KEY){
Serial.println(customKey);
}
}
There are 8 pins on my 4x4 keypad.
With the code uploaded to Arduino R3 board.When i Connect pin1(Keypad) to (Arduino Board digital) pin2
(keypad)pin2 to (Arduino Board) Pin 3 and so for...
But when i monitor on the serial monitor, it is showing some incorrect pins as in some of button got no responds.
Please Advise

You have to make sure that you are connecting the columns on the arduino to the columns on your keypad, likewise the rows on your keypad must be in the rows on the arduino.

byte rowPins[ROWS] = {3, 2, 1, 0}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad

The problem I see here is that you seem to be using pins 0 and 1 in the rows. These two lines are used by the serial port so change that line to:-

byte rowPins[ROWS] = {3, 2, 8, 9}; //connect to the row pinouts of the keypad

Then make sure you know what are columns and what are rows on your keypad.

Also note the code is in boxes. Go and click modify on your last post, Select the code and hit the # icon next to the quote and save the result.

Sorry, Can I check with you on how do I determine what are columns and what are rows of my keypad?
As my keypad had only 8 pins only. Is it the same as per recommended by you earlier?

Can I check with you on how do I determine what are columns and what are rows of my keypad?

The best way is to look up the data sheet.
Or you can look at how the PCB is wired up.

As Mike says...there is really no way to tell as you havent even told us what keypad you are using.. pictures...nothing. :fearful:

but using THIS code: (slightly different than Mikes edit..but more or less the same)

// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 2, 3, 4, 5, };

// Connect keypad COL0, COL1, COL2 and COL3 to these Arduino pins.
byte colPins[COLS] = { 6, 7, 8,9 };

it would be wired as such:

Hi,

Thanks alot for your help. I am able to use the Keypad.
By the way if i want to use Arduino Uno R3 with the keypad and program as a calculator with simple calculations like addidtion only
is it possible? Where can I find the library or function for it?What do you advise?

if you already can communicate with the kaypad..

I would think any handling of your 'data' would/could be done internally..

grab the key1 data.. and add it to the key2 data..etc..

maybe set up some keys to set the operator..etc.. just some simple logic..

Yes but you need the suspended stored operation.
Get in one number.
Read the operation you want to perform, store it because you can't do that until you ..
Get the second number.

In that respect reverse polish calculators were great.

Sorry in this case, I just need to modify the source code from under the void loop function?
Is there any more advise on how to edit the program? Like some link or something?
As I am not too sure on how to start.

I just need to modify the source code

What source code?

Has anyone used a resistor network as a voltage divider and then read the key value off one of the analog input pins?

I read a write up on something like this but it used resistors of odd values. ( Odd means I didn't have any )

The one I say was set up like a straight ladder and the input came off the mid-point. I thought that there might be a way to use 8-10 1K resistors in a network to accomplish the same thing.

Here is what you might have been thinking of.
http://tronixstuff.wordpress.com/2012/02/29/tutorial-analog-input-for-multiple-buttons-part-two/
Expand the network for the number of buttons you want to use.

CrossRoads:
Here is what you might have been thinking of.
http://tronixstuff.wordpress.com/2012/02/29/tutorial-analog-input-for-multiple-buttons-part-two/
Expand the network for the number of buttons you want to use.

I was actually looking at something like:
http://www.avr-asm-tutorial.net/avr_en/keypad/keyboard.html#adc

This one is for a 3X4 matrix and the math is a pain for selecting the resistor values. I was hoping some smarter folks than me figured out a way to use only 1 or 2 different values.

Hi,
I had already tried to interface with 4x4 keypad with arduino and it works... Currently I am thinking of modifying the source code so that
it can function as a calculator(Simple Calculator with just addition function). But I am not sure how to start with the advises given earlier.
Is it modifying in the void loop function?
Please Advise.

CustomKeypad1.ino (905 Bytes)