# Self-made Arduino pushbutton bank not working

So I'm trying to make a 5 key keypad like circuit, but with increased tactile feel, so I forwent actual store bought pushbuttons. I rigged up keys with some aluminum foil and pieces of plastic and connected that to 5V. All of the buttons share this 5V. Then, I made some contact pads of aluminum foil that has one lead sandwiched between two layers. This lead had two wires, one that connected to one of the digital I/O's and one that connected to a resistor that then connected to ground. All of the contacts share the resistor( and therefore ground). So when the plastic piece connected with the sandwiched piece, it becomes a button. This works, I've tried it. What I can't fix is that if I only connect the pin for Digital 2, then push down any button, not just the one connected to pin 2, it registers a push.

Here is the code I use to check for presses :

int ledPin = 13;
int val = 0;

void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
for(int x = 2;x<6;x++){
pinMode(x, INPUT);
}

}

void loop(){
/*for(int x = 2;x<6;x++){
if (val == HIGH) {
digitalWrite(ledPin, LOW);
Serial.println(x);
} else {
digitalWrite(ledPin, HIGH);
}
}*/
Serial.println("2");
digitalWrite(ledPin, LOW);
} else {
digitalWrite(ledPin, HIGH);
}

}


The commented part was intended to check for all 5 connections, while the uncommented part only checks for pin 2.

You need to have a resistor per button. If you don't then any keypress will raise the common node to +5V and they will all register the keypress.

• So I would need an individual resistor to all contacts? Can they be connected to a common ground? Also, do they have to have different resistances? – nadjatee1996 Aug 26 '14 at 0:51
• So I would need an individual resistor to all contacts? YES Can they be connected to a common ground? YES Also, do they have to have different resistances? NO – MatsK Aug 26 '14 at 1:15
• Just a final comment before I resolder the contacts, can one of you explain why this solution works? I think I understand it, but I kinda want confirmation. By having a resistor on each contact pad, does it insure that each pad raises the resistance a certain amount? So the Digital In can read if the voltage changed by a certain amount and only read for that pin? – nadjatee1996 Aug 26 '14 at 1:34
• The resistors prevent there from being a common node between all switches, thereby preventing them from all becoming the same voltage at the same time. – Ignacio Vazquez-Abrams Aug 26 '14 at 2:20
• @nadjatee1996, if you look closely at the drawing, Digital2 is directly short-circuited to Digital3, and their short-circuited connection is pulled down via your resistor. If Digital3 is "actuated", +5V is delivered to the short-circuit between Digital2 and Digital3. – TDHofstetter Aug 26 '14 at 4:33