@Grumpy_Mike
My code looks like this.
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {29, 34, 33, 31}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {30, 28, 32}; //connect to the column pinouts of the keypad
void setup(){
Serial.begin(9600);
}
void loop(){
for (int i = 0; i < COLS; ++i) {
pinMode(colPins[i], INPUT);
//digitalWrite(colPins[i], HIGH);
}
for (int i = 0; i < ROWS; ++i) {
pinMode(rowPins[i], INPUT);
digitalWrite(rowPins[i], HIGH);
}
for (int i = 0; i < COLS; ++i) {
pinMode(colPins[i], OUTPUT);
digitalWrite(colPins[i], LOW);
for (int j = 0; j < ROWS; ++j) {
Serial.print(keys[j][i]);
Serial.print(": ");
Serial.println(digitalRead(rowPins[j]));
}
pinMode(colPins[i], INPUT);
//digitalWrite(colPins[i], HIGH);
}
delay(5000);
}
It's the same as keypad's library.
@mstanley
Thank you for your effort, but please, don't loose too much time on this. I'm pretty sure it's a wiring problem. I have NO idea where the problem is. I've checked for short circuits, i've checked every connection, i've even checked my protoboard for possible factory faults..
I am pretty sure pin assignments are correct. I've checked at least 5 times, i've read the tutorial on keypads and applied the same procedure. I used continuity check and it beeps as expected when i press the right buttons. One of my first thoughts was the same tho, i find it weird that there's no order at all in pin assignments.
Still, at this point, i am convinced there's a problem with wiring or pin assignments (but as far as i know (i kinda suck at math :D), no other permutations would work, continuity check works as expected on every single key..), at least that's the only thing i can deduce from above code's output. Or maybe a short circuit, i've no idea.. I must be missing something really stupid lol. And i'm really sorry for the hassle heh, thanks for helping everyone. Cheers, Val
Output:
If i don't press anything:
1: 0
4: 1
7: 1
*: 0
2: 0
5: 1
8: 1
0: 0
3: 1
6: 1
9: 1
#: 1
Ok this might be more representative:
0 0 1 1 2 3
1 1 1 4 5 6
1 1 1 7 8 9
0 0 1 * 0 #
If i press '2':
0 0 1
1 1 1
1 1 1
0 0 1
'5':
0 0 1
0 0 1
1 1 1
0 0 1
'8':
0 0 1
1 1 1
0 0 1
0 0 1
'0':
0 0 1
1 1 1
1 1 1
0 0 1
'1':
0 0 0
1 1 1
1 1 1
0 0 0
'4':
0 0 1
0 1 1
0 1 1
0 1 1
'7':
0 0 1
1 1 1
0 1 1
0 1 1
'*':
0 0 0
1 1 1
1 1 1
0 0 0
EDIT:
The result when not pressing anything can only suggest a short circuit, since every button should have read HIGH.. What else could it be, but multimeter doesn't detect any short circuits..
EDIT:
Ok, i've connected 5V to any pin, and all other pins get 5V on them! How the hell is that possible if there is no short circuits!.. Is that some open collector thingy? I thought keypads were simple switches, just wires..