Skip to content


m4 2x2 in lego

M4 2x2 nrf52840 zmk M4 2x2 rp2040 qmk M4 2x2 rp2040 zmk

an ortholinear keyboard set in lego 2x2 with optional encoder and oled. this uses seed studio xiao rp2040 or seed studio xiao nrf52840... these are test beds for something else. xiao boards are nice since they are small but the do not have a lot of pins... so i used two chained shift registers for columns... this is simply a playground for porting the 5x13 to xiao. Another consequence since qmk does not support xiao yet, firmware is zmk.

in the xiao family there are other boards samd21, sense and esp32c3... I do not have them so I did not test them that means they may work or not. Feel free to send me one of them if you want me to test.

this is part of a bigger family of ortholinear keyboards in lego see for reference

Please note that I am aware of the xiao contest for mechanical keyboards and their fusion pcb assembly service. while none was used for this project, seeed studio kindly agreed to sponsor 5x13 version with pcbs and MCUs.

status: all ok

  • gerbers designed
  • firmware
  • breadboard tested
  • gerbers printed
  • board tested


  • 2x2
  • 1 encoder, optional
  • oled, optional
  • 5 pins
  • seeduino xiao nrf52840 or xiao rp2040, others too probably but not tested
  • firmware zmk


M4 2x2


  • kicad pcb

M4 2x2 front pcb

M4 2x2 back pcb


  • 1 seeed studio xiao nrf52840 or seeed studio xiao rp2040 pins
  • 4 signal diodes 1N4148 , do 35 or sod-123
  • 1 encoders
  • 2x7 pin DIL/DIP sockets whatever you prefer
  • 2x7 pin male headers, rounded or straight to match the socket
  • 5 pin MX switches 4
  • 2 HC595 shift registers... surface mount
  • lego 8x12 plate for bottom, and bricks as you please


lego... 8x12 for plate... you can use 2x(4x12) plates with the normal legos as described here

case information can be found here


this is a very rushed assembly guide but shall give you the main idea.


gerbers ready to be printed at jlcpcb are available

full kicad project if you want to generate your own or modify is available here kicad symbols/footprints are in the m65 repo


at the moment only zmk.


xiao nrf52840

source available here


xiao rp2040

source available here

since rp2040 is supported in qmk

source is here to build it, just follow

  git clone --recurse-submodules -b mlego qmk-alin
  cd qmk-alin
  qmk compile -kb mlego/m4/rev2 -km default

  make mlego/m4/rev2:default
  # copy the resulting uf2 on the mcu as per instructions.


  • rows: 1 - D0, 4 - D3

  • c0: shift register 1 - QA

  • c1: shift register 2 - QA

** 74HC595N **

  • data: 11 - D10
  • latch: 8 - D7
  • clock: 9 - D8


  • Pad_A: 2 - D1
  • Pad_B: 3 - D2


  • SDA: 5 -D4
  • SCL/SCK: 6 - D5

other pictures

M4 2x2 M4 2x2 M4 2x2