Introduction: Create Own Membrane Matrix Keypad (and Hooking It Up to the Arduino)

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

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?


Step 2: Collecting the Materials.

The really cool thing about this instructable is you probably already have all the things you need to build this in your house! Yes when I say that this is a simple, cheap, effective way of making a keypad I mean that it is simple and cheap. For this instructable you will need:

Aluminum Foil (tin foil... some sort of foil) *foil tape works well also
Some sort of paper or flat material (what you choose here will effect the durability. I'm using a dry erase pad for my fridge)
glue (unless you're using foil tape)
and a spacer of some sort (a few layers of paper with holes cut in them may work I'm using double sided sticky foam pads)

Laminator (COMPLETELY OPTIONAL)

Step 3: Decision Time

Picture of Decision Time

The first step to putting your keypad together is deciding what you want it to look like/how many buttons do you want on it. For this instructable I will be using a 3X3 setup with the numbers from 1 to 9 on it. Once you have decided what it will look like draw it out and decide where you want all the wires to go. I want a lead off from my keypad so it will go around my door so see image 2 for what mine should look like. Make a mock up on your computer using whatever software you like (paint, photoshop, illustrator...) and proceed to the next step.

Step 4: Mapping Out Your Cheap "Circuit"

Picture of Mapping Out Your Cheap "Circuit"

What we are going to be doing is gluing on foil to make a flexible, cheap, however effective circuit board. What we need to do now is on our computer mock up we need to make how our columns and rows are going to be set-up. If you are using Photoshop make 2 new layers, one called rows the other columns. if you're just using paint make a copy of the file called rows and another columns.

On these new layers we will put large black lines where we want our "Circuits" to go. See image 2 for rows and image 3 columns if you are confused. Image 4 shows what both layers turned on looks like. Starting to look familiar?
Now you need to flip one of your images vertically... or is it horizontally... see image 5 you'll get what I mean.

Go ahead and print these out for the next step.

Step 5: Faux Circuit Making Time!

Picture of Faux Circuit Making Time!

Here is the fun part... well in my opinion the whole thing is fun but whatever...
Now that you have your printed out templates you can start making your circuit. Now is the time to glue down your foil where ever your rows and columns are supposed to go. Look at figure 2 for both of my circuits, yours should look somewhat like this. Also, notice how my leads go away from the keypad in an organized way to facilitate easy hook-up? Just like I planned!

*NOTE* At this point its a good idea to re-make your front design to include labels for the hookup at the end of the leads with the labels
R1
R2
R3
C3
C2
C1

This is just going to make it easier for you.

Step 6: Putting It All Together.

Picture of Putting It All Together.

In the next step we will be putting it all together. Take your spacers and apply them to one side of your keypad. come to think of it you could technically use silicone (the type used for caulking) as a really decent spacer... I may try this in the future actually.... hmm..

Anyways back on topic. To apply these spacers we need to make sure that there is a hole in the center of them so that the rows and columns can contact one another when they are depressed (not sad... pressed down). I kinda just tiled everything but you could use a hole punch or something to get better results. The spacers are also there to make sure other parts of our circuit do not touch each-other incidentally.

Take a look at image 1 to see all the spacers applied appropriately. Once your spacers have been applied (you may need to glue whatever you are using) you may put the other side of your keypad on top of this one (image 2). Luckily you made sure that everything was mapped out properly on your template on the computer... you did make a template didn't you?

Image 3 is the pieced together keypad.

*****OPTIONAL STEP*****
To help my keypad enjoy a long healthy life I laminated mine. It helps provide some structural support for the paper... constant pressing can and will create depressions (again not sad) in the paper that sooner or later will cause your keypad to become ineffectively pressing that button constantly.

Image 4 would show my beautiful laminated Matrix style keypad however the laminator ate my piece of art.

Step 7: Arduino Anyone?!

Time to hook up your keypad to the Arduino for the first time... exciting no?

Well Exciting as it may be it'll have to wait for now! The Laminator lovingly ate my keypad so until I can find the time to make another one then it'll have to wait. I WILL be coming back so do not to worry this step will come. Perhaps in the near future I will explain how to set it all up and not exactly show it off. For now here is the arduino code I was using with my prototypes for those of you who know where to go from here good luck. For the others sit tight.

***NOTE*** you will have to install the keypad library from arduino.cc




Comments

Pokaloka (author)2016-05-14

we can add some antistatic foam in some holes to have variable resistance contacts

Alderin (author)Pokaloka2016-11-16

Unfortunately, that wouldn't work in a matrix-style sensing arrangement. A large part of the matrix pattern depends on a very binary state of the switches. If there were to be a resistance behind each button, power would flow from any column, through the buttons on the row, through the rows to the other columns, and you end up with one big switch.

In order for variable resistance switches to work, you'd have to have clever use of diodes and/or additional resistors to block selection power and classify each button into a different, detectable resistance range... and equally clever software to figure out just what which level signal on this line actually means.

Not impossible, but not as easy as antistatic foam.

RossL14 (author)2016-07-03

Aww what an adorable laminator. I hope it has a little smiley face on it :) I am hoping to make a proper flexible membrane matrix for a project, with about 75 buttons. Will there be enough inputs on the arduino? I know there is a component that multiplies the available in/outs.

Pokaloka (author)2016-05-14

and making 4 matrixes on 4 cd 4060 (oscillator inside) outputs and connect them to 4 cd4069 amp stages and then inside 4 cd4069 drum generators and you (I suppose) get a 4 analog sound polyrythm drum sequencer/ looper :)

Pokaloka (author)2016-05-14

I made a magnetic patchbay :

https://www.instructables.com/id/Magnetic-Patchbay-...
and now, gonna make your switch matrix for my synths :)

Pokaloka (author)2016-05-14

thanks a lot :)

MuhammetK4 made it! (author)2016-02-27

thank you bro, I made it thanks to you

ly333 (author)2010-02-19

Ok I finished mine I used tape and hot glue to connect leads to a cable I found I hope it works...This is what i looks like...Also how do I connect it to my arduino?

ly333 (author)ly3332010-02-19

The leads and everything is exactly the same as the one from the top to bottom. cables goes from top to bottom in order.

TheBestJohn (author)ly3332010-02-19

 That is awesome my friend! well stick the columns into pins 3, 4, and 5, and the rows into pins 6, 7, and 8. Also if you have a buzzer stick it into pin 13 and ground. then load up the code included here and open up serial monitor in at 9600 baud. Press a button and you should see it pop up on the monitor! 

Note: Make sure you have installed the keypad library from arduino.cc Make a video if you have the time. I'd love to see it!

NavedA2 (author)TheBestJohn2015-10-22

Great Idea but still confusing how to keep spacer between two sheets.

ly333 (author)ly3332010-02-19

So I labelled it from top to bottom X1-3 Y1-3

MattMac1975 (author)2015-08-12

And then?

TheBestJohn (author)MattMac19752015-08-12

Take a look at the pde file. It's pretty straightforward. You plug in the wires into digital ins and run the code. I unfortunately destroyed this project in a laminator and was unable to take pictures of that process

umpteee (author)2013-07-15

If you want an alphabetical keyboard for Arduino check out this DIY Keyboard from LucidTronix: http://lucidtronix.com/tutorials/44

jvan lierde (author)2013-06-26

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

jvan lierde (author)2013-06-25

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

jvan lierde (author)jvan lierde2013-06-25

The includes are: Keypad, password and servo

TheBestJohn (author)jvan lierde2013-06-25

best bet, Serial.println(key); and make sure the numbers are the ones you're pressing first.

TheBestJohn (author)TheBestJohn2013-06-25

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)TheBestJohn2013-06-25

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

roachburn (author)2011-08-01

I combined this instructable with Arduino 3 wire Matrix Keypad : https://www.instructables.com/id/Arduino-3-wire-Matrix-Keypad/
it works very nicely. Thanks for the fun and interesting project. :)

TheBestJohn (author)roachburn2011-08-02

That's an awesome Idea! I'd love to see pictures if you have the time!

espy13 (author)2011-05-10

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)espy132011-05-10

#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

}

}

espy13 (author)TheBestJohn2011-05-12

Thank you very much I got the sample working.

TheBestJohn (author)espy132011-05-12

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)espy132011-05-10

the include is < keypad.h >

EngineerJakit (author)2011-03-11

If possible, this method could be used to make a modded cell phone part?

hvandenberg (author)2010-06-22

any progress on hooking up the arduino? im stuck at that step

TheBestJohn (author)hvandenberg2010-06-22

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.

Javi93 (author)2010-04-21

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)Javi932010-04-22

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.

nixoid (author)2010-02-21
Why would you post an incomplete Instructable - not cool.
 
charlie_r (author)nixoid2010-02-21

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_r2010-02-21

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.

Geosync (author)TheBestJohn2010-02-21

Eaten? The original keypad was eaten?   Great article.  Looking forward to reading more.

TheBestJohn (author)Geosync2010-02-21

 Eaten by the laminator lol it was a mess and I wish I had pictures

wocket (author)TheBestJohn2010-02-22

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)wocket2010-02-22

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.

mdawg22 (author)TheBestJohn2010-04-12

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

bighamms (author)2010-02-21

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)bighamms2010-02-21

 I sure do just really busy lately. While you are waiting make sure to look up Arduino tutorials ;)

leo_bergamo (author)TheBestJohn2010-03-10

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.

mdawg22 (author)leo_bergamo2010-04-12

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?

mdawg22 (author)2010-04-11

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!

ratgod (author)2010-03-11

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.

funtimems (author)2010-02-21

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)funtimems2010-02-21

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.

leo_bergamo (author)TheBestJohn2010-03-10

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!