Decoding a 4x16 Switch Matrix on Arduino for Conditional Logic

I'm looking to decode an existing switch matrix (4 Rows and 16 Columns, basically copy the states of the Rows and Columns).
The goal is to ultimately have a [data] where I will have:
ROW 1 == LOW && COL 1 == LOW, which will result in DATA == LOW.
In my case, only INPUTs are needed, the Arduino should not generate the matrix but only read it (so no OUTPUTs).
After obtaining this variable [DATA], I need to add a condition Supp [DATA] && x == 1 to store it in another variable in order to pass it into a SWITCH CASE.
Then, I can do things like: (but I have 64 switches)
if (ROW 1 == LOW && COL 1 == LOW) {
// for example, turn a LED to HIGH
}
else {
// if necessary
}
if (ROW 1 == LOW && COL 1 == LOW) {
// for example, turn a LED to HIGH
}
else {
// if necessary
}
Solution:
Use a nested loop instead of the switch.
Jump to solution
4 Replies
Camila_99$$
Camila_99$$2mo ago
attachment 0
Camila_99$$
Camila_99$$2mo ago
I haven’t found any code that allows me to solve this issue.
Solution
ZacckOsiemo
ZacckOsiemo2mo ago
Use a nested loop instead of the switch.
wafa_ath
wafa_ath2mo ago
The MatrixKeypad library does this very well. https://github.com/victorsvi/MatrixKeypad You can install it from the IDE's library manager.
GitHub
GitHub - victorsvi/MatrixKeypad: Simple to use Arduino library to i...
Simple to use Arduino library to interface matrix keypads. - victorsvi/MatrixKeypad
Want results from more Discord servers?
Add your server