cancel
Showing results for 
Search instead for 
Did you mean: 

keyboard diode matrix scanning

chriskuku
Senior III

I'm faced with connecting a (piano) keyboard to an MCU using a number of columns and a number of rows.
The principle is shown in the attached photo.  I've read approaches where the coulmns are pulled to low while the rows are inputs that are sensed.

Am I right that with the given arrangement it would be appropriate to set the columns to "HIGH" and sense the rows whether they are "HIGH"? 

Mittel (IMG_0354).jpeg

 

Excuses, forgot to say which MCU: it's an STM32F103C8T6 here.
The diodes are common  practice to avoid so called "ghost hits" when multiple contacts are actuated.

9 REPLIES 9
mƎALLEm
ST Employee

Hello,

Could you please state what STM32 are you using?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
MM..1
Chief III

Explain for what you use diodes here?

I edited the original message.

Yes i know for what, but miss your piano info then multipress detecting require it. More safe method is use pullups in MCU and OD (open drain) mode for line scaning to GND...

Requirement is to detect every key press, also multiple ones, but avoid wrong ones (ghost).

Could you explain the circuit then to catch every key pressed. Pullups to what, outputs, inputs or both?

Pull to ground using open drain?

Without diodes for only one key at time, but safe press more. With diodes multi key allowed.

MM1_0-1777189614552.png

in your variant if no diodes or failed diode you can short with two buttons press out high to out low , result to destroy out driver pin ... With open drain and internal pull ups no risk.

And the 0.7V forward voltage is recognized safely as a logic "0"?