Instructables

Create own Membrane Matrix Keypad (and hooking it up to the Arduino)

Featured
Picture of Create own Membrane Matrix Keypad (and hooking it up to the Arduino)
So you want to create your own membrane keypad? Why? well making your own keypad can be useful for many reasons. It's cheap and easy to do, it can be placed in situations where it may be vandalized or stolen without much frustration, It can be fully customized to display whatever you like, and you can make as large a keypad as you like with as many inputs as you can handle. I created my keypad to go on the exterior of my door in residence to act as a keypad entry in much the same way as colin353 did here www.instructables.com/id/An-Electronic-Door-Opener/. I however have some more tricks up my sleeve for this coming up in a later Instructable.

****NOTE: This is not a complete instructable for the time being. It goes through the construction of a keypad fully, however it does not yet fully explain or demonstrate the means to make it useful. This will change

 
Remove these adsRemove these ads by Signing Up

Step 1: Understanding the Keypad

   The first thing I want you to understand is how this keypad works. I know what you're thinking... Matrix keypad?... "I'm not going to have to take any blue pills to get this to work am I?". No its not that matrix.. The best way to think about a matrix style keypad is to think about battleship.

   A matrix is pretty much a grid like in battleship consisting of rows and columns. each button corresponds to a certain row and column. See the first picture to help illustrate this better. On a 9 button keypad you would use 3 rows and 3 columns. The first button would make a link between Row 1 and Column 1 (R1C1) just like in battleship. 2 would be R1C2, 3 R1C3, and lets say 8 would be R3C2... the rest are illustrated on the image.

   The point of this is instead of having 9 different buttons to wire up, all you would need to do is wire up 3 columns and 3 rows for significantly less wires. The real benefits come when you begin adding buttons. adding another row and column (2 wires) would add 7 buttons... see where I'm going?


1-40 of 85Next »
umpteee1 year ago
If you want an alphabetical keyboard for Arduino check out this DIY Keyboard from LucidTronix: http://lucidtronix.com/tutorials/44
Hye, I've changed the 9 and 7 into a '#' and a "*". Now it looked like it did run right for about a minute and then he just started ignoring the password en took the '#' as enter without reading the password! I guess I changed something the wrong way. I'll keep trying. :)
Hye, I made this membrane. Now I'm trying to hook it up with a servo what i've got is this:
#include
#include
#include



Servo myservo;
Password password = Password( "123" );

const byte ROWS = 3; // Four rows
const byte COLS = 3; // columns
// Define the Keymap
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 5, 4, 3};// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 8, 7, 6 };


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

void setup(){
myservo.attach(9); //servo on digital pin 9
Serial.begin(9600);
keypad.addEventListener(keypadEvent); //add an event listener for this keypad
}

void loop(){
keypad.getKey();
}

//take care of some special events
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
Serial.print("Pressed: ");
Serial.println(eKey);
switch (eKey){
case '#': checkPassword(); break;
case '*': password.reset(); break;
default: password.append(eKey);
}
}
}

void checkPassword(){
if (password.evaluate()){
Serial.println("Success");
//Add code to run if it works
myservo.write(160); //160deg
digitalWrite(11, HIGH);
delay(500);
digitalWrite(11, LOW);
}else{
Serial.println("Wrong");
//add code to run if it did not work
myservo.write(10); //10 deg
digitalWrite(12, HIGH);
delay(500);
digitalWrite(12, LOW);
}

}


Now the problem is it won't react to the key "123". I did try some things out like changing the "#" for check password into a number like 9 or something. Then the servo moves every time number 9 is pushed but still does not react to "123". What am I doing wrong? Can you help me out? Greets
The includes are: Keypad, password and servo
TheBestJohn (author)  jvan lierde1 year ago
best bet, Serial.println(key); and make sure the numbers are the ones you're pressing first.
TheBestJohn (author)  TheBestJohn1 year ago
Looks like you are doing that... do several printIns at different points in your code to help narrow down where it's breaking
TheBestJohn (author)  TheBestJohn1 year ago
Oh i see whats wrong... you have no # key here... case '#': checkPassword(); is never called because there is none set up... set up a push button or something for a pound key
roachburn3 years ago
I combined this instructable with Arduino 3 wire Matrix Keypad : http://www.instructables.com/id/Arduino-3-wire-Matrix-Keypad/
it works very nicely. Thanks for the fun and interesting project. :)
TheBestJohn (author)  roachburn2 years ago
That's an awesome Idea! I'd love to see pictures if you have the time!
espy133 years ago
Does anyone have a copy of the code for the arduino? Can't get it from here it just saves a blank file.

thanks.
TheBestJohn (author)  espy133 years ago
#include

int beep = 13; //A buzzer is attatched to pin 13

const byte ROWS = 3; //four rows
const byte COLS = 3; //four columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
};


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

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

void setup(){
Serial.begin(9600);
pinMode(beep, OUTPUT);
}

void loop(){
char key = keypad.getKey();
if (key != NO_KEY){
Serial.println(key);
digitalWrite(beep, HIGH); // set the buzzer on
delay(100);
digitalWrite(beep, LOW); // set the buzzer off

}

}
Thank you very much I got the sample working.
TheBestJohn (author)  espy133 years ago
Great! post up a picture I'd love to see it!

It makes me feel like people are really benefiting from it when I get to see others examples of it
TheBestJohn (author)  espy133 years ago
the include is < keypad.h >
If possible, this method could be used to make a modded cell phone part?
hvandenberg4 years ago
any progress on hooking up the arduino? im stuck at that step
TheBestJohn (author)  hvandenberg4 years ago
Sorry for the wait. I just Graduated so I'll have some time shortly to finish this up. to give you the gist of it is to take the code at the bottom and hook up the rows to pins 3, 4, and 5 and the columns up to 6, 7, and 8 and run the code. Make sure you have downloaded the keypad library from arduino and have it installed. if the numbers show up but aren't the right ones try moving those connections around.
Javi934 years ago
Wonderful!
Only got one question: im making a multicolour led cube for my room and I was wondering if that keypad could be used to change the colour? for example: number 1 for red, number 2 for blue, etc.
TheBestJohn (author)  Javi934 years ago
defiantly! That's actually the first thing I did with this thing. Control the colors of an RGB LED that I had obtained... be sure to ask for some samples from a company called lumex... they'll send you some awesome samples of RGB leds that are wickedly bright.
nixoid4 years ago
Why would you post an incomplete Instructable - not cool.
 
He did say in the intro that it would be a "work in progress", meaning that it will be added to as he has time and/or new steps completed.


Kudos to you Jorad! Great ideas!
TheBestJohn (author)  charlie_r4 years ago
Thanks Charlie! Also Nixoid, I decided to post this after having it half written for a month. I finished what information I had however my original keypad was eaten so I could not take pictures of the final step of hooking it up. In my defense all the information needed to do this is in the instructable. I included all the code you need and if you read the comments you'll find that someone has already built the entire keypad and gotten it working. Also I am active on instructables, if you want to build it and have any questions, I am here.
Eaten? The original keypad was eaten?   Great article.  Looking forward to reading more.
TheBestJohn (author)  Geosync4 years ago
 Eaten by the laminator lol it was a mess and I wish I had pictures
laminators love to eat anything thats not really flat. perhaps putting the pads on after laminating? I'm a complete nubie to all this make your own electronics stuff, could you explain some basics in this wonderful instructable or point out some links?

love the idea, can't wait to see what it could be used for.

could you make a while typing keypad or rolled up piano keypad this way?
TheBestJohn (author)  wocket4 years ago
You most likely could. Look up the arduino if you want a good introduction into microcontroller programming and whatnot. it's really easy to pick up and run with and there are thousands of tutorials for it out there.
there is already a roll-up-piano keyboard. I have one, but sadly i took it apart.

I had a very bad habit of taking things apart a while ago, thinking i could make them better. (Hmmm.... maybe i could combine my cell phone with my psp! oops....)

Now my keyboard is broken. :)
bighamms4 years ago
Jarad,  hope you plan to complete this ible.  I am intrigued.  I would like to understand how to use the keypad when complete.  I'm assuming it interfaces with arduino.  I have no clue what arduino is or how to use it, but am guessing that I will know when you complete the projects. thanks in advance, look forward to it.
TheBestJohn (author)  bighamms4 years ago
 I sure do just really busy lately. While you are waiting make sure to look up Arduino tutorials ;)
Dumb question,  but how are you identifying the buttons on the Arduino.  The reason I am asking because my limited electronics knowledge tells me you should have a unique hot and a common ground for each button.  I did not see this.  Could you explain alittle.

This project is very intresting as I am a car PC enthuisiast and have pretty much hand made all the electrical interfaces that went along with it.  I could name about 100 applications for this when it comes to car PC's.  I would like to use an old USB game pad witch I have already tapped the button hots and grounds to all the buttons with small stranded wire.
the answer to your first question is that (obviously) Aluminum foil is an electric conductor. There are 6 pieces of foil, 3 for the horizontal and 3 for the vertical.

Lets name these first three A, B, and C. The second three are 1 2 and 3.

The combinations for the 9 numbers are A1, A2, A3, B1, B2, B3, C1, C2, and C3.

the arduino will recognize which Horizontal (A, B or C) input connects to which Vertical (1, 2, or 3) output.

so, assuming that the number 1 is A1, the number 3 is A3, the number 4 is B1 and so on, the combination 6, 7, and 2 would be B3, C1, and A2.

Get it now?
mdawg224 years ago
WOW! ever since i was little i always wanted one of these bad boys.. i didn't know it was that easy!! Thanks man! 5 stars!
ratgod4 years ago
Excellent instructable.
I did something like this many years ago when I was interested in building my own computer from scratch, the most dificult part in my eyes were the spacers, I used card with holes in it but the paper+foil would eventually sag. it looks like you used foam type spacers, I will have to try it myself.

I also considered making a trackpad type device (years before they were on laptops) by making very fine strips of foil going vertically on one side and horizontaly on the other, same principal as the keypad but it would have been a nightmare to read electronically and very unreliable.
funtimems4 years ago
I would suggest laminating the front cover (one side) before assembling the keypad entirely.  Or get some wide clear packaging tape and laminate it yourself with tape.
TheBestJohn (author)  funtimems4 years ago
I haven't experimented much with all these different methods. I had thought of that and I figured that I was just using it for my dorm door, which means drunk freshmen ripping everything they see down in the hall so I didn't want to put too much time into it in case it was destroyed. Thats why I love instructables though. You can make it that way and post your results for others to see how it went.
How are you identifying each button press.  Are you measuring resistance.  The reason I ask is not every button has it's own seperate contact.  The ground I imagine would not matter.  The reason I am asking is instead of using an Arduino I want to actually interface it to an old USB game pad wich I have already tapped the ground and button leads with small wire. 

Great project!
It's a matrix layout that's how 6 wires can be used to sense the 9 buttons.
jamwaffles4 years ago
Genius! All those arduino projects will now have a pro touch :P

Nice work.
sniper69jr4 years ago
If i was going to connect some wire to the circuit how would i do that because if you solder it well melt through the tin foil.
TheBestJohn (author)  sniper69jr4 years ago
well I origionally taped mine on.... then I was planning on making some sort of clamp for easy release. tape then hot glue would probably be your best bet
1-40 of 85Next »