interfacing with a non matrx keypad

Hi i have a 3x4 button keypad wich doesn seem to be matrix. it has one "com" contact and 12 others, which connect to the com one, every time each button is pressed. so all the buttons have one common ground.
How do i interface that keyboard with arduino?

You use twelve inputs.

Or use your own data selector like a 74LS154 or two 74LS151s.

You need to have some kind of pull-up on each input so that it is high until a button is pressed. As they are buttons, surely you could just use a common +V if you wanted to instead...

Mowcius

No you need a common ground and then you need pull up resistors or if you use TTL multiplexers like I said these inputs will tend to float high. However pull up resistors will give better noise immunity.

sorry guys i forgot to mention that i am a complet newb to arduino.
Can you be more detailed? I want to build this project:Arduino + Sparkfun 12 button keypad part 1 - YouTube

How should i modify the code in order to use my keypad?

Yes, it should be really easy though. Just requiring more pins.

Mowcius

How should i modify the code in order to use my keypad?

What code, go on post it (using the # button) or post a link.

Can you post a schematic?(how should i connect it using diodes)
Or i doesnt worth the effort and i should buy a matrix keypad
Btw thanx for the help everyone :slight_smile:

******************BEGIN SKETCH******************
#include <Keypad.h>
#include <Password.h>

Password password = Password( "1337" );

const byte ROWS = 4; //four rows
const byte COLS = 3; //four columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

byte ledPin = 13;
byte ledPin2 = 12;

boolean programMode = false;

int speakerPin = 9;

void setup(){
Serial.begin(9600);
pinMode(ledPin, OUTPUT); // sets the digital pin as output
pinMode(ledPin2, OUTPUT); // sets the digital pin as output
pinMode(speakerPin, OUTPUT); // sets the speakerPin to be an output
digitalWrite(ledPin, LOW); // sets the LED off
digitalWrite(ledPin2, LOW); // sets the LED off
keypad.addEventListener(keypadEvent); //add an event listener for this keypad
startupSound();
}

void loop(){
char key = keypad.getKey();
}

//take care of some special events
void keypadEvent(KeypadEvent key){
switch (keypad.getState()){
case PRESSED:
switch (key){
case '#': guessPassword();
digitalWrite(ledPin, LOW);
break;
case '*': password.reset();
resetSound();
digitalWrite(ledPin, LOW);
digitalWrite(ledPin2, LOW);
break;
default : if (key != NO_KEY){
Serial.print("Key Pressed = ");
Serial.println(key);
}
password.append(key);
digitalWrite(ledPin, HIGH);
analogWrite(speakerPin, 128);
break;
}
break;
case RELEASED:
switch (key){
default : digitalWrite(ledPin, LOW);
analogWrite(speakerPin, 0);
break;
}
break;
}
}
void guessPassword(){
if (password.evaluate()){
digitalWrite(ledPin2,HIGH);
Serial.println("Password ");
//Serial.println(key);
Serial.println(" Correct");
openSound();
delay(3000);
digitalWrite(ledPin2,LOW);
password.reset();
}else{
digitalWrite(ledPin2,LOW);
Serial.println("Password ");
//Serial.println(key);
Serial.println(" Incorrect!");
password.reset();
errorSound();
}
}
void resetSound() {
int n = 100;
for (int vez=0;vez<6;vez++){
for (int _=0;_<100;_++){
delayMicroseconds(n);
digitalWrite(speakerPin, HIGH);
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin2, LOW);
delayMicroseconds(n);
digitalWrite(speakerPin, LOW);
digitalWrite(ledPin, LOW);
digitalWrite(ledPin2, HIGH);
}
delay(20);
}
}
void errorSound() {
int n = 2000;
for (int vez=0;vez<1;vez++){
for (int _=0;_<200;_++){
delayMicroseconds(n);
digitalWrite(speakerPin, HIGH);
digitalWrite(ledPin, HIGH);
delayMicroseconds(n);
digitalWrite(speakerPin, LOW);
digitalWrite(ledPin, LOW);
}
delay(50);
}
}
void openSound() {
int n = 300;
for (int vez=0;vez<3;vez++){
for (int _=0;_<100;_++){
delayMicroseconds(n);
digitalWrite(speakerPin, HIGH);
delayMicroseconds(n);
digitalWrite(speakerPin, LOW);
}
delay(100);
}
}
void startupSound() {
int note = (1/587.33)*500000;
for (int _=0;_<100000/note;_++){
delayMicroseconds(note);
digitalWrite(speakerPin, HIGH);
delayMicroseconds(note);
digitalWrite(speakerPin, LOW);
}
note = (1/659.26)*500000;
for (int _=0;_<100000/note;_++){
delayMicroseconds(note);
digitalWrite(speakerPin, HIGH);
delayMicroseconds(note);
digitalWrite(speakerPin, LOW);
}
note = (1/523.25)*500000;
for (int _=0;_<100000/note;_++){
delayMicroseconds(note);
digitalWrite(speakerPin, HIGH);
delayMicroseconds(note);
digitalWrite(speakerPin, LOW);
}
note = (1/261.63)*500000;
for (int _=0;_<100000/note;_++){
delayMicroseconds(note);
digitalWrite(speakerPin, HIGH);
delayMicroseconds(note);
digitalWrite(speakerPin, LOW);
}
note = (1/392.00)*500000;
for (int _=0;_<200000/note;_++){
delayMicroseconds(note);
digitalWrite(speakerPin, HIGH);
delayMicroseconds(note);
digitalWrite(speakerPin, LOW);
}
}
********************END SKETCH******************

Ok to do it with diodes you need 5 input pins on the arduino. It is rather a big diagram.

or full size:-


Software needed, make pins 2 to 6 inputs. Pin 6 is the strobe this goes high when any key is pressed. The binary number of the pressed key is on bits 2,3,4 & 5.
Common key pad connection to +5V

Hi the schematic even on full size is a little bit small, and i cant distinguish the pins.

Also, I didnt understand how I should modify the sketch..

the schematic even on full size is a little bit small

Down load it into a picture viewer and use the zoom. I have made sure the resolution is OK to show everything.

and i cant distinguish the pins.

It dosn’t matter what pins you use any input pins will do.

Also, I didnt understand how I should modify the sketch…

You don’t you write another, this works in a totally different way.

If you have the strobe line on pin 6 than when this goes high some key is being pressed. To find out what key number it is you do:-
keyNumber = (digitalRead(2) << 3) | (digitalRead(3) << 2) | (digitalRead(4) << 1) | digitalRead(5) ;

If you are clever you can eliminate the 12 strobe diodes, but then you have to compensate in software by subtracting one from the number. In that case a number reading of zero indicates no key is pressed.

and pulling the bus lines down to ground

The problem with pulling down with diodes is that you still have 0.7V on the input which is on the limit for a normal logic zero. That’s why you are better pulling up.