3
\$\begingroup\$

Hi all, I'm making a project to read my old calculator's keyboard with an arduino and I've decided to design a new PCB and change it with the original one, as it's easier than trying to hook into the old circuit.

I'm working in EasyEDA and it's nearly done, but I'm confused about how and where to connect the Ardunio's GND pin to the circuit. I know it has to be connected to the input pins(see below), but I'm not sure if directly... or just how in general. I'm completely new to PCB design and electronics, so if you see anything off, please point it out. I'd be more than happy to hear your thoughts on the design, feel free to share it.

The output pins are where 5v will be applied and the inputs are going to be read. I haven't decided on the diodes' type yet, so the one you see are the default diodes, EasyEDA has in the schematic designer.

My design:

enter image description here

(the yellow circles are the exact positions of the keys on the original PCB)

And one more thing. I saw people use the "Copper Area" option in tutorials many times, but I have no idea what that does, could someone provide any inside on what is it used for?

Ps.: I've got complaints about how I'm not asking a specific question, but please understand that I'm new to this thing. I'm not lazy googleing, but I can't search for something I don't even know about, and I have no other platform to ask these questions.

Thanks in advance!

\$\endgroup\$
14
  • 2
    \$\begingroup\$ Why do you want to connect ground somewhere? That is a button matrix, so none of the pins must not be connected directly to ground or supply. \$\endgroup\$
    – Justme
    May 28, 2020 at 11:55
  • 1
    \$\begingroup\$ No. The Arduino includes keypad matrix library, so you really don't need to do anything else than read one of the tutorials how they work. But in short, the MCU sets its outputs to VCC or GND to scan one row(or column) at a time and and reads all the inputs for one row(or column). \$\endgroup\$
    – Justme
    May 28, 2020 at 12:11
  • 1
    \$\begingroup\$ Um, please explain your final edit. Why would the need of ground connection depend on if you use a ready made library or scan it with your own code? The code still needs to be scanning the matrix in exactly same way. \$\endgroup\$
    – Justme
    May 28, 2020 at 12:33
  • 1
    \$\begingroup\$ @SadatRafi to allow for reading any number of simultaneously held keys. \$\endgroup\$
    – Justme
    May 28, 2020 at 12:38
  • 1
    \$\begingroup\$ @SadatRafi every tutorial I've seen uses or mentions the use of diodes. Could you explain your side? \$\endgroup\$ May 28, 2020 at 12:46

2 Answers 2

3
\$\begingroup\$

The keyboard matrix does not use a ground connection to operate. The MCU sets the output pins to VCC or GND to scan a single row (or column) at a time, and then reads the input pins to see which buttons are activated on the selected row (or column).

And no, the need for ground connection does not change based on if you use a ready-made library or write your own code.

\$\endgroup\$
4
  • \$\begingroup\$ Ookay I'm lost. I saw an an algoritm which just sets one column high, scans for high values on each row, than moves on to the next column, and repeat. I'm sorry for my confusion, but there's a way to write code that makes a ground connection unneccesary? Could you describe it briefly or link a tutorial or anything to get me on the right track so we can continue the conversation? \$\endgroup\$ May 28, 2020 at 12:44
  • \$\begingroup\$ Is this a good example? baldengineer.com/arduino-keyboard-matrix-tutorial.html \$\endgroup\$ May 28, 2020 at 12:57
  • 1
    \$\begingroup\$ As good as any other example. See, there is no ground connection anywhere in the matrix, only GPIO inputs and outputs. The MCU pins either provides GND or VCC as programmed by GPIO. \$\endgroup\$
    – Justme
    May 28, 2020 at 13:47
  • \$\begingroup\$ Yes, thanks for you patience... and sorry for my confuison again. \$\endgroup\$ May 28, 2020 at 13:54
4
\$\begingroup\$

enter image description here

in the comment section, you have said that you are using Arduino. Common Arduino uses AVR microcontroller. The picture I have included above is from the datasheet of ATMEGA16. The GPIO pins you see externally are connected to this type of logic circuit internally.

The I/O pins are controlled by mainly two registers. One is called the Data Direction Register, and another is the PORT Register. The red marked block represents DDR bit. If it is set to 1, the tristate buffer (green circle) will be turned on, and the value of the PORT register (blue box) will appear at your external pin.

Any value of the external pin is stored in the PIN Register. If the DDR bit is 0 then the buffer will be turned off. And if the pull-up system is disabled too, your pin would be in a floating state. If an external input comes, then it can't pass through the buffer and can't cause a short circuit with the PORT Register bit. It goes toward the transmission gate and the synchronizer circuit and its state i.e. 1/0 is stored in the PIN register.

All you have to do is giving a logic 1 to one line (i.e. DDR bit = 1 & PORT bit =1) and declare other bits as input( i.e. DDR bit 0). Then check the value of the PORT register.

In Arduino, Data Direction Registers are controlled by ' pinMode(); ' function.
PORT Registers are controlled by ' digitalWrite(); ' function.
PIN Register values are checked by ' digitalRead().; ' function.

enter image description here

The red lines represent a switch press event. I guess you have understood why the diodes and the ground connection are unnecessary.

\$\endgroup\$
3
  • 3
    \$\begingroup\$ You can change the answer. But do note that your question was about where to connect ground, and this answer does not answer that question, it aswers to how to read matrix keyboard with Arduino. And the necessity of diodes depend on if the purpose is to detect all simultaneous button pushes (needed) or only few simultaneous buttons (not needed), so it is not correct to say that they are not needed, if the circuit purpose is not known. \$\endgroup\$
    – Justme
    May 28, 2020 at 15:34
  • 1
    \$\begingroup\$ If he needs to detect multiple button presses at the same time, diodes are needed. Just imagine 3 buttons are pressed: the ones connected to D22, D23 and D24. Without diodes your circuit would detect D25's button pressed as well. If NKRO is not a necessity (e.g. at most 2 buttons at once are enough in a simple calculator), diodes can be omitted. en.wikipedia.org/wiki/… \$\endgroup\$
    – Nyos
    May 28, 2020 at 22:03
  • \$\begingroup\$ In normal dot matrix keypad, people press one button at a time. And this is a tiny PCB. So I considered simultaneous action as pressing two buttons. You are correct that it won't work for three inputs. \$\endgroup\$
    – Sadat Rafi
    May 28, 2020 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.