Hello, hope you all are having a good day.
I aint that experienced with Arduino or electronics in general but Im doing a project a small project, using a keyboard matrix. At first it works totally fine but obviously, phantom keys are a problem.
So my scheme here works fine, in simulation (with Proteus) or irl, with the 4x4 tactile keypad. However, once i put a diode, the button that I put the diode with wont work. And yes, i tried to follow the scheme of keyboard matrix, but i dont seem to understand it very well, as my code works without diodes but when they are introduced, it stops.
Here's my code:
#include <Keypad.h>
int rows=4, cols=4;
char keys[4][4]= {
{'1','2','3','4'},
{'5','6','7','8'},
{'9','A','B','C'},
{'D','E','F','G'}
};
byte colPins[4]={5,4,3,2};
byte rowPins[4]={6,7,8,9};
Keypad kp = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);
void setup() {
Serial.begin(9600);
Serial.println("PROJECT");
kp.setHoldTime(2000);
}
void loop() {
if (kp.getKeys()){
for (int i = 0; i<LIST_MAX; i++){
if ( kp.key[i].stateChanged ){
switch (kp.key[i].kstate) { // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
case PRESSED:
Serial.print(kp.key[i].kchar);
Serial.println(" is PRESSED.");
break;
case HOLD:
Serial.print(kp.key[i].kchar);
Serial.println(" is on HOLD.");
break;
case RELEASED:
Serial.print(kp.key[i].kchar);
Serial.println(" was just RELEASED.");
break;
}
}
}
}
}
And here's the scheme that i made:
So my question is:
1- Where is the problem?
2- Why are the diodes preventing it from working?
3- Any solution please?
Thank you so much