(Using Arduino Pro Micro)
Hello, I am new to electronics and I decided to make a pcb to build my own usb controller for pc (it is not a good idea to do such a big project just arrived at electronics, I know
). So when the pcb arrived, I assembled the pieces, I made the code to be able to detect the buttons and I realize that they make me wrong readings (Floating input). After consulting solutions, I tried to use the INPUT_PULLUP but the problem was not fixed.
So I wanted to see if I could do the following to try to fix it:
(attached pictures)
Also I attach my code (maybe the mistake is here) (Its a test code for testing the matrix, not the final code), which consists on be sending row per row a voltage and checking which column pin is LOW when I push a button.
int rowPins[] = {9,8,7,6,10};
int colPins[] = {16,14,15,18,19,20,5};
int colPin;
void setup() {
for (int i = 0; i < 5; i++) {
pinMode(rowPins[i], OUTPUT);
digitalWrite(rowPins[i], LOW);
}
for (int i = 0; i < 7; i++) {
pinMode(colPins[i], INPUT_PULLUP);
digitalWrite(colPins[i], LOW);
}
}
void loop() {
colPin = 0;
for (int i = 0; i < 5; i++) {
digitalWrite(rowPins[i], HIGH);
delay(250);
for (int col = 0; col < 7; col++){
if(digitalRead(colPins[col]) == HIGH)
{
colPin = 0;
}
else{
colPin = colPins[col];
break;
}
delay(250);
}
if(colPin > 0){
Serial.print(rowPins[i]);
Serial.print(" AND ");
Serial.print(colPin);
Serial.print("\n");
}
digitalWrite(rowPins[i], LOW);
}
}
I hope I have explained well what I wanted to say :D.

