12-keypad reading with 7 pins, I'm confused

Hi, I have a school project where I need to make a working vault-door by reading out a 12 button display, with 3 inputs and 4 outputs. The columns are put in series, and the rows are put in series as well. All the column-pins are inputs with a pull up resistor. So, when nothing is pressed, all three inputs for the collumns are high, but as soon as one of the buttons is pressed the signal runs through the button to the input for the row.
lay-out toetsenbord kluisassesment
so, when the third button is pressed, COL3 goes low and ROW1 goes high. But so far I've only been able to read out that COL3 is low (with ROW1 as an output set to low). What I want to know is how to read out if, in this given instance, COL3 is low AND ROW1 is high, so that I can run it through an 'if'-command and turn on a led to check if the 'if'-statement (COL3 is low, ROW1 is high) is true?

Keyboard-Matrix-Tutorial

Further reading:

https://www.gammon.com.au/forum/?id=14175

Sad to say that none of this code makes sense to me, since I'm in my first year. Nearly nothing in the examples in both of those articles has been explained by our teachers yet. I think I'll leave this as is, and get on to figuring out a way myself with my project-partner. Still thanks for the input and help.

So please tell us what was the most advanced thing that your teacher did explain yet!

This forum works this way:
You start writing a piece of code yourself. If a question arises post the question in combination with your code that you have written so far.

Or in this case you start studying the suggested code yourself. If a question arises post the question and the code.

As an example:
The code at baldengineer starts with

// Keyboard Matrix Tutorial Example
// baldengineer.com
// CC BY-SA 4.0
  
// JP1 is an input
byte rows[] = {2,3,4};
const int rowCount = sizeof(rows)/sizeof(rows[0]);

it might be that you have never seen before a "[ ] = {2,3,4}"
So you simple ask:
"what does this line of code

byte rows[] = {2,3,4};

do?
Can somebody explain it or post a link to an explanation?

You could add some guessing what you assume what it might be:

example: is byte rows some kind of byte-variable?

By posting this way you show that you started thinking / analysing the code yourself.

This makes the big difference compared to a question like
"can somebody post the ready to use code how to scan a keyboard?"

In this way you create a customized tutorial which is specialised to your needs. The open secret is show some own effort in learning.
So give it a try! Post your question! What ever your question might be.
best regards Stefan

If you are serious and want to learn this stuff make the effort to learn from all resources, don’t wait to be lead by your instructor.

i was surprised to see the matrices with diodes. i've built them just using the built-in pull-up resistors. of course they're not designed for multiple buttons be pressed at the same time

perhaps another hindrance is a limited understanding of hardware.

buttons are conventionally connected between a pin and ground and the pin can be configured with an internal pull-up resistor that makes the input HIGH when the button is not pressed and becomes LOW when pressed (connected to ground)

each input pin is connected to a row of buttons where each button is also connected to column pin. each input is configured with a pull-up (INPUT_PULLUP). each output is alternately configured as an input or a LOW output

when scanning, the configuration for each column pin is sequentially configured from a simple input (no pullup, INPUT) to a LOW output. only one output pin is ever configured as a LOW output

as each column is made LOW, the row pins are read to see if any are LOW. while there are several buttons connected to that input pin, if it is LOW it must be the button connected to the column pin being configured as a LOW output

the row and column of the pressed button can be used to read the button ID from a 2 dimensional array

(don't forget to reconfigure the column pin as an input after each scan and after detecting a LOW input)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.