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

• 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