

Midi matrix 4x4
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.mdDIY 机械轴 MIDI 键盘 — PCB 组装与接线
适用板子:midi_matrix_4x4.kicad_pcb(16 键单排钢琴布局,316×66mm 双层板,
电气上 4×4 矩阵)。键位从左到右 K0..K15 = MIDI 音符 60..75(C4..D#5)。
物料清单
| 物料 | 数量 | 说明 |
|---|---|---|
| Cherry MX 兼容机械轴 | 16 | 5 脚 PCB 安装轴(3 脚板载轴也能焊,但没有定位柱固定) |
| 1N4148 二极管(DO-35) | 16 | 方向必须全部一致,见下文 |
| 1×8 排针(2.54mm) | 1 | 焊在 J1 |
| RP2040-Zero(Waveshare) | 1 | 刷 CircuitPython 9.x |
| 杜邦线(母对母) | 8 | 连接 J1 与 RP2040-Zero |
焊接
按从矮到高的顺序焊:二极管 → 排针 → 轴。
-
二极管 D1..D16(最关键,别焊反) 每个键上方有一只 1N4148,横放。丝印上本体左侧有一条粗线标记——那是 阴极(色环端)。二极管玻璃体上的黑色/彩色环必须朝这个标记(左侧焊盘, 即靠近轴体 pin1 的那一端)。16 只全部同向(COL2ROW,阴极朝行线)。 焊反一只,对应键就完全没反应(或整行/列行为异常)。
-
排针 J1 板子左边缘的 1×8 竖排针。从正面插入,背面焊接。 pin1 在丝印斜角/方焊盘处,pin1..8 旁边有数字 1..8 丝印。
-
MX 轴 SW1..SW16 对准 5 个孔(2 个电气脚 + 中心柱 + 2 个定位柱)按入,焊两个电气脚即可。 注意丝印键号 K0 在最左、K15 在最右。
接线(J1 → RP2040-Zero)
8 根杜邦线一一对应,不需要接 GND(矩阵全是 GPIO 直连,主控由 USB 供电):
| J1 pin | 信号 | RP2040-Zero |
|---|---|---|
| 1 | ROW1 | GP1 |
| 2 | ROW2 | GP2 |
| 3 | ROW3 | GP3 |
| 4 | ROW4 | GP4 |
| 5 | COL1 | GP5 |
| 6 | COL2 | GP6 |
| 7 | COL3 | GP7 |
| 8 | COL4 | GP8 |
即 J1 pin k → GPk,直插到底即可。
固件
- RP2040-Zero 刷 CircuitPython 9.x(waveshare_rp2040_zero 版 UF2),
并把
adafruit_midi库拷到 CIRCUITPY 盘的lib/。 - 把本仓库的
matrix_16key.py拷到 CIRCUITPY 盘,改名code.py。 - 上电后电脑应直接识别为 USB MIDI 设备(Linux 免驱)。
固件行为:行线轮流拉低扫描、列线内部上拉,5ms 消抖,固定力度 80,
串口(USB CDC)打印 note on <n> / note off <n>。
验证
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| Qty | Value | Footprint | References |
|---|---|---|---|
| 16 | 1N4148 | diy:D_DO-35 | D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, D16 |
| 4 | MountingHole_M3 | diy:MountingHole_M3 | H1, H2, H3, H4 |
| 1 | K0 (C4) | diy:SW_Cherry_MX_1U | SW1 |
| 1 | K1 (C#4) | diy:SW_Cherry_MX_1U | SW2 |
| 1 | K10 (A#4) | diy:SW_Cherry_MX_1U | SW11 |
| 1 | K11 (B4) | diy:SW_Cherry_MX_1U | SW12 |
| 1 | K12 (C5) | diy:SW_Cherry_MX_1U | SW13 |
| 1 | K13 (C#5) | diy:SW_Cherry_MX_1U | SW14 |
| 1 | K14 (D5) | diy:SW_Cherry_MX_1U | SW15 |
| 1 | K15 (D#5) | diy:SW_Cherry_MX_1U | SW16 |
| 1 | K2 (D4) | diy:SW_Cherry_MX_1U | SW3 |
| 1 | K3 (D#4) | diy:SW_Cherry_MX_1U | SW4 |
| 1 | K4 (E4) | diy:SW_Cherry_MX_1U | SW5 |
| 1 | K5 (F4) | diy:SW_Cherry_MX_1U | SW6 |
| 1 | K6 (F#4) | diy:SW_Cherry_MX_1U | SW7 |
| 1 | K7 (G4) | diy:SW_Cherry_MX_1U | SW8 |
| 1 | K8 (G#4) | diy:SW_Cherry_MX_1U | SW9 |
| 1 | K9 (A4) | diy:SW_Cherry_MX_1U | SW10 |
| 1 | RP2040 GPIO | diy:PinHeader_1x08_P2.54mm_Vertical | J1 |
Similar boards
- 2 layers40 × 34 mm

- 2 layers53.9 × 23.2 mm

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 mm

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 mm

FreeDeck SMD 2020-02
FreeYourStream/freedeck-hardware
all the stuff you need to build your own FreeDeck
37 parts772 - 2 layers65 × 28 mm

BMS Cell Module
stuartpittaway/diyBMS
Do it yourself battery management system for Lithium ion battery packs/cells
37 parts676GPL-3.0 - 2 layers48 × 32 mm

FlatSat
Pwnsat/FlatSat
Flatsat v1.0 is a hardware based platform for aerospace cybersecurity research
37 parts575GPL-2.0 - 2 layers38.1 × 153.7 mm

- 2 layers47.8 × 27.4 mm

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.