Skip to the content
2 layers316 × 66 mmMidi matrix 4x4, the printed circuit board in 3D

DIY mechanical-switch MIDI keyboard (RP2040 + CircuitPython)

Size
316 × 66 mm
Copper layers
2
Thickness
1.6 mm
Parts
37
Nets
24
Pads
124
Tracks, vias
88, 32
Routed
Yes
KiCad
KiCad 7.0 (file 20221018)
Created
19 Oct 2026
Updated
26 Oct 2026

Overview

Midi matrix 4x4 is an open-source printed circuit board by JohnQsk, from the JohnQsk/diy-midi-keyboard repository on GitHub. It is a 2-layer board of 316 × 66 mm with 37 parts on 24 nets, routed with 88 tracks and 32 vias.

Its parts include 16 diodes, 16 switches and 1 connector. It belongs with the audio and music and lEDs and displays boards and the RP2040 boards of this library.

README

README.md

DIY 机械轴 MIDI 键盘 — PCB 组装与接线

适用板子:midi_matrix_4x4.kicad_pcb(16 键单排钢琴布局,316×66mm 双层板, 电气上 4×4 矩阵)。键位从左到右 K0..K15 = MIDI 音符 60..75(C4..D#5)。

物料清单

物料数量说明
Cherry MX 兼容机械轴165 脚 PCB 安装轴(3 脚板载轴也能焊,但没有定位柱固定)
1N4148 二极管(DO-35)16方向必须全部一致,见下文
1×8 排针(2.54mm)1焊在 J1
RP2040-Zero(Waveshare)1刷 CircuitPython 9.x
杜邦线(母对母)8连接 J1 与 RP2040-Zero

焊接

按从矮到高的顺序焊:二极管 → 排针 → 轴。

  1. 二极管 D1..D16(最关键,别焊反) 每个键上方有一只 1N4148,横放。丝印上本体左侧有一条粗线标记——那是 阴极(色环端)。二极管玻璃体上的黑色/彩色环必须朝这个标记(左侧焊盘, 即靠近轴体 pin1 的那一端)。16 只全部同向(COL2ROW,阴极朝行线)。 焊反一只,对应键就完全没反应(或整行/列行为异常)。

  2. 排针 J1 板子左边缘的 1×8 竖排针。从正面插入,背面焊接。 pin1 在丝印斜角/方焊盘处,pin1..8 旁边有数字 1..8 丝印。

  3. MX 轴 SW1..SW16 对准 5 个孔(2 个电气脚 + 中心柱 + 2 个定位柱)按入,焊两个电气脚即可。 注意丝印键号 K0 在最左、K15 在最右。

接线(J1 → RP2040-Zero)

8 根杜邦线一一对应,不需要接 GND(矩阵全是 GPIO 直连,主控由 USB 供电):

J1 pin信号RP2040-Zero
1ROW1GP1
2ROW2GP2
3ROW3GP3
4ROW4GP4
5COL1GP5
6COL2GP6
7COL3GP7
8COL4GP8

即 J1 pin k → GPk,直插到底即可。

固件

  1. RP2040-Zero 刷 CircuitPython 9.x(waveshare_rp2040_zero 版 UF2), 并把 adafruit_midi 库拷到 CIRCUITPY 盘的 lib/。
  2. 把本仓库的 matrix_16key.py 拷到 CIRCUITPY 盘,改名 code.py。
  3. 上电后电脑应直接识别为 USB MIDI 设备(Linux 免驱)。

固件行为:行线轮流拉低扫描、列线内部上拉,5ms 消抖,固定力度 80, 串口(USB CDC)打印 note on <n> / note off <n>。

验证

bash
aconnect -l                  # 应看到 USB MIDI 设备
aseqdump -p <端口>           # 按键应出现干净的 Note On/Off 配对
python3 keydash.py           # 或用串口仪表盘实时看按键状态(需 pip install pyserial)

发声:QSynth/FluidSynth 加载 SoundFont(如 FluidR3_GM.sf2,忘加载是最常见的"没声音"原因), 然后 aconnect <键盘端口> <fluidsynth端口>。

排障

  • 某个键没反应 → 先查该键的二极管方向,再查轴体两个焊点。
  • 一整行(K0-3 / K4-7 / K8-11 / K12-15 之一)没反应 → 查对应 ROW 的杜邦线/GP 口。
  • 一列(K0,K4,K8,K12 这种间隔 4 的)没反应 → 查对应 COL 的杜邦线/GP 口。
  • 按键串扰/鬼键 → 基本就是某只二极管焊反或漏焊。

Parts

37
QtyValueFootprintReferences
161N4148diy:D_DO-35D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16
4MountingHole_M3diy:MountingHole_M3H1, H2, H3, H4
1K0 (C4)diy:SW_Cherry_MX_1USW1
1K1 (C#4)diy:SW_Cherry_MX_1USW2
1K10 (A#4)diy:SW_Cherry_MX_1USW11
1K11 (B4)diy:SW_Cherry_MX_1USW12
1K12 (C5)diy:SW_Cherry_MX_1USW13
1K13 (C#5)diy:SW_Cherry_MX_1USW14
1K14 (D5)diy:SW_Cherry_MX_1USW15
1K15 (D#5)diy:SW_Cherry_MX_1USW16
1K2 (D4)diy:SW_Cherry_MX_1USW3
1K3 (D#4)diy:SW_Cherry_MX_1USW4
1K4 (E4)diy:SW_Cherry_MX_1USW5
1K5 (F4)diy:SW_Cherry_MX_1USW6
1K6 (F#4)diy:SW_Cherry_MX_1USW7
1K7 (G4)diy:SW_Cherry_MX_1USW8
1K8 (G#4)diy:SW_Cherry_MX_1USW9
1K9 (A4)diy:SW_Cherry_MX_1USW10
1RP2040 GPIOdiy:PinHeader_1x08_P2.54mm_VerticalJ1

Similar boards

  • 2 layers40 × 34 mmDD HIP9011, the printed circuit board in 3D

    DD HIP9011

    rusefi/rusefi

    rusefi - GPL internal combustion engine control unit

    37 parts1.2k
  • 2 layers53.9 × 23.2 mmAnalog, the printed circuit board in 3D

    Analog

    hoglet67/RGBtoHDMI

    Bare-metal Raspberry Pi project that provides pixel-perfect sampling of Retro Computer RGB/YUV video and conversion to HDMI

    37 parts1kGPL-3.0
  • 2 layers52 × 51.8 mmEsp32-homeassistant rf bridge, the printed circuit board in 3D

    Esp32-homeassistant rf bridge

    hackclub/OnBoard

    💡 Join 1,000 teenagers and make your first PCB with a $100 grant!

    37 parts915
  • 2 layers87.8 × 59.8 mmFreeDeck SMD 2020-02, the printed circuit board in 3D

    FreeDeck SMD 2020-02

    FreeYourStream/freedeck-hardware

    all the stuff you need to build your own FreeDeck

    37 parts772
  • 2 layers65 × 28 mmBMS Cell Module, the printed circuit board in 3D

    BMS Cell Module

    stuartpittaway/diyBMS

    Do it yourself battery management system for Lithium ion battery packs/cells

    37 parts676GPL-3.0
  • 2 layers48 × 32 mmFlatSat, the printed circuit board in 3D

    FlatSat

    Pwnsat/FlatSat

    Flatsat v1.0 is a hardware based platform for aerospace cybersecurity research

    37 parts575GPL-2.0
  • 2 layers38.1 × 153.7 mmDEFOG PANEL, the printed circuit board in 3D

    DEFOG PANEL

    jrsteensen/OpenHornet

    OpenHornet 1:1 F/A-18C Simulator Repository

    37 parts431
  • 2 layers47.8 × 27.4 mmVsf stm32h7b0, the printed circuit board in 3D

    Vsf stm32h7b0

    vsfteam/vsf

    Versaloon Software Framework -- a tiny preemptive-capable event-driven incremental software framework for embedded systems

    37 parts341Apache-2.0

Questions

How big is the Midi matrix 4x4 PCB?

It measures 316 × 66 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Midi matrix 4x4 use?

37 parts. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Midi matrix 4x4 KiCad files?

From the JohnQsk/diy-midi-keyboard repository on GitHub, at the commit this page was made from: the board is midi_matrix_4x4.kicad_pcb and its schematic midi_matrix.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Midi matrix 4x4 design in my own project?

Its repository states no licence, so its author keeps all rights: ask JohnQsk before reusing the design.