Pages: [1] 2   Go Down
Author Topic: how do I interface with a 4x4 keypad/  (Read 4970 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

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

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 509
Posts: 31478
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 509
Posts: 31478
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Quote
as i tried to connect the o/p pin to the port of arduino
Not sure what you are trying to do.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 509
Posts: 31478
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.

Quote
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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







Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 509
Posts: 31478
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Code:
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:-
Code:
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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 509
Posts: 31478
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

0
Offline Offline
Edison Member
*
Karma: 7
Posts: 1221
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As Mike says...there is really no way to tell as you havent even told us what keypad you are using.. pictures...nothing.  smiley-eek-blue



but using THIS code: (slightly different than Mikes edit..but more or less the same)
Code:
// 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:

Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Offline Offline
Edison Member
*
Karma: 7
Posts: 1221
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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..

Logged


Manchester (England England)
Online Online
Brattain Member
*****
Karma: 509
Posts: 31478
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1] 2   Go Up
Jump to: