Skip to main content
chriskuku
Senior II
April 24, 2026
Question

keyboard diode matrix scanning

  • April 24, 2026
  • 2 replies
  • 154 views

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.

2 replies

mƎALLEm
Technical Moderator
April 24, 2026

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."
chriskuku
chriskukuAuthor
Senior II
April 24, 2026

I edited the original message.

MM..1
Chief III
April 24, 2026

Explain for what you use diodes here?

chriskuku
chriskukuAuthor
Senior II
April 24, 2026
MM..1
Chief III
April 24, 2026

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...