Hi.
Edit at the end......
I have a nodemcu esp32 and want to make this matrix.
...a little matrix of 2x2 of reed switches.
This switches can be all 4 closed at the same time.
in this little matrix with diodes
G | H |
---|---|
g2 | h2 |
g1 | h1 |
I use this gpio for columns: gpio36, gpio39
this for rows: gpio23, gpio22
Because... i dont know how to do this, i try to just know what is happening in the code like this:
const int columnPins[] = { 36, 39};
const int rowPins[] = { 23, 22};
int COLH;
int COLG;
int FILA1;
int FILA2;
void setup() {
Serial.begin(115200);
for (int i = 0; i < 2; i++)
{
pinMode(columnPins[i], INPUT_PULLUP);
pinMode(rowPins[i], OUTPUT);
//digitalWrite(columnPins[i], HIGH);
//digitalWrite(columnPins[i], LOW);
}
}
void loop()
{
COLH=digitalRead(columnPins[0]);
COLG=digitalRead(columnPins[1]);
FILA1=digitalRead(rowPins[0]);
FILA2=digitalRead(rowPins[1]);
Serial.println("Debería ser H1");
Serial.println(COLH);
Serial.println(FILA1);
Serial.println("Debería ser G1");
Serial.println(COLG);
Serial.println(FILA1);
Serial.println("Debería ser H2");
Serial.println(COLH);
Serial.println(FILA2);
Serial.println("Debería ser G2");
Serial.println(COLG);
Serial.println(FILA2);
delay(100);
}
To say the true... i already try changing everything, that is why i think that probably i fried my device... and it is not working.
What is wrong with this code? Maybe the gpio that i choose are not suitable for this?
With this code i was trying to see the state of the columns and rows, to later change the code to reflect when a switch is open or closed... but i dont see nothing consistent. And i change from high to low, from column input_pullup to output and rows input_pullup to output and viceversa......... and nothing is good.
thank you very much
Edit:
I try now this code from here change the rows and columns two my size and gpio setup Issues with 3x3 Matrix of Reed Switches - #2 by flashko
that seems wrote from somebody that knows. But it is also not working. I have the same problem that that person tell in that post.... Bad readings.
After that a person recommend the register shifters BUT, it is suppose that this could be done in a Matrix with diodes. Then it must work in some way! Well, if somebody knows what is going here?!