Saturday, June 4, 2016

Cherry MX Keypad

In this post I will document an open-source, Arduino-compatible Cherry MX keypad that I designed using the ATmega32U4 microcontroller.

 A highly customizable Cherry MX keypad.


You have probably heard of Cherry MX keys in relation to gaming keyboards. They are very nice keys with excellent tactile feel. They are also extremely durable and rated for 50 million keystrokes. Products that use them are often top-tier and pricey, but come with cool features like multi-colored backlighting and re-programmable keys. Many people customize their keyboards by changing the key caps to have custom labels and colors. But why stop there? Let's design our own Cherry MX keypad from scratch!

Board Overview

The board that I designed includes four Cherry MX keys. I used MX Blues, but it is also compatible with other types such as Brown and Red. It's simply a matter of soldering on the ones you want. The keys are backlit by 3mm LEDs that sit in recesses in the sides of the keys. They are controlled via PWM to allow changing the brightness. The microcontroller running the show is an Atmel ATmega32U4. This is the same microcontroller used on the Arduino Leonardo. In fact, this board looks like a Leonardo to the Arduino IDE for programming. There is an ISP port for burning the bootloader with a programmer (Atmel ICE, USBtinyISP, etc), but you only need to do that once. Afterwards simply connect the board to your computer using the Micro USB connector for programming and normal usage.

The lovely ATmega32U4. Adding USB to the project with this chip couldn't be simpler.

The left side of the board with the microcontroller is a good example of a minimal setup for the 32U4. Despite the small number of components, we still have a good 16MHz crystal, reverse polarity protection on the 5V USB line, and the necessary bypass capacitors. If you modify this board to add more keys, you can bring over most of this layout as-is.


Using this board is super easy. After flashing the Leonardo bootloader, you can upload the example program on Github over USB from the Arduino IDE. You'll see from the example sketch that the code is simple and easy to modify. After uploading a program, the board immediately re-mounts as a USB input device. Pressing the keys sends the characters you have programmed to the computer just as if it were a keyboard or mouse. You could also program in character strings and complex combinations of key presses, mouse clicks, and delays. See this reference on the Arduino page to learn about all of the keyboard and mouse commands that you can use to program your own key functions.

Check out my YouTube video on the Cherry MX keypad to see it in action:


Not only is the programming of the keypad entirely customizable, the hardware is as well. This is shared as an open-source project. You can use the Eagle files as a template to make your own numeric keypad or even a full keyboard! Adding Cherry MX keys to your project really steps it up a level, especially if you create or 3D print a nice enclosure to mount them in. Remember that these keys are not just about tactile feel. They are extremely durable, and you can purchase or make your own custom keycaps to add the finishing touches to your project's interface.

Using Cherry MX keys in this project gives us access to all of the awesome
custom keycaps available. These metal arrow keys look and feel great.

I used the internal pull-ups on the 32U4 for the key switch circuits, and debouncing is done in software. There is plenty of space around the keys on the board for adding hardware debouncing if you like.

With only four keys on the board, I was able to connect each one to an individual pin of the microcontroller. However, if you make a large board with several keys, this will not be possible. You will need to switch over to row-and-column scanning to be able to handle something like a full keyboard. There are also some interesting things you could do with the backlighting. You could put the LEDs on a parallel charlieplexed grid, allowing you to turn on individual ones. This would be useful for key press indication, making games like Simon Says, and adding cool lighting effects.

Shared as Open Source Hardware (OSHW)

Here's the information you need to assemble your own Cherry MX keypads using the PCB I designed or design your own.

Eagle Files and Example Program: Shared on Github
Cherry MX Keypad: Order PCBs on OSHPark!

Cherry MX Keypad Schematic

 Cherry MX Keypad Layout

Parts List:

Microcontroller: Atmel Atmega32U4 TQFP
LEDs: 4x 3mm Green (or substitute with LEDs that have the same compact dimensions)
USB Connector: FCI 10103594-0001LF
D1: BAT20J or similar schottky diode, SOD-323 package
Q1: MMBT2222A NPN transistor, SOT-23 or similar NPN with same footprint
Y1: 16MHz, 5x3.2mm 4-lead SMD crystal
Programming Header: Standard AVR ISP 2x3 0.1" header (no need to actually solder it)
C1: 4.7uF 0603 SMD
C2: 100nF 0603 SMD
C3: 1uF 0603 SMD
C4, C5: 22pF 0603 SMD (or adjust value based on crystal load capacitance)
R1: 10k 0603 SMD
R2, R3: 20 ohm or 22 ohm 0603 SMD
R4, R5, R6, R7: 330 ohm 0603

Notes: Be sure to get the "PCB Mount" version of the Cherry MX keys, such as the part numbers shown in the links above. They have the necessary "fixation pins" for stability on the board. The 3mm LED needs to have a very small rim and short height to seat fully into the side of the MX key body. Any substitute needs to have similar dimensions to the part number linked above or it may protrude above the key body and interfere with the keycap.

Soldering Note: Be sure to examine the pictures, footprints, and part dimensions to ensure you can successfully assemble this board. I did use hot air for the crystal and USB connector. They can be done with an iron, but hot air and solder paste is more reliable.

Wrap Up

I hope you find this project interesting. As I said, it is really just a template for designing your own Cherry MX keypad. You can modify it to make it easier to solder, expand the board to include many more keys, or customize it to your intended enclosure. Tweet me a picture @sync_channel if you make some of these boards or design your own custom Cherry MX keypad. I'd love to see it!

Also let me know what you thought of the YouTube video. I have wanted to add video content to my articles for some time, and this is a first attempt at it. I have nothing close to a proper setup for making videos, so I apologize for the poor quality. Perhaps in the future I will invest in some better lighting and equipment to improve my videos. This written blog will always be my primary means of sharing my projects however.

Thanks for reading!

- Dan W.


  1. Dan, The video was great and adds lots to the blog. I can see many applications for the Cherry MX keypad. Thanks for another great post.

  2. Great project! and video. Will it work durring boot ?

  3. This comment has been removed by the author.

  4. hello, awesome project! Im trying to recreate an 8 switch version of this, and I cant seem to get the arduino IDE to recognize it. I've getting the .hex file from the temp folder to upload it in FLIP (didn't work..)
    I've tried flashing the bootloader several different ways (arduino as ISP, bus pirate, directly through usb; nothing)
    can you elaborate on how you got the ATMEGA32U4 to take some code? Thanks!

  5. This is a great article. I have taken your design and modified it into a 24 key keypad, all with LED's. Thanks for taking the time to create this blog.

    1. Hello,

      I would like the 24 button version too, but I do not have the Eagle skills... Would you be so kind and share the design? It will save me a lot of time :)