just another keypad

Similar projects worth following
21 mechanical keys configured as a numerical keypad plus 4 programmable macro keys.

Another write-up can be found at

The main features of this keypad include:

  • HID compliant USB peripheral using an ATmega32U4 microcontroller with connectivity via a USB type-c connector configured as a USB 2 device. Power is also derived from the USB port.
  • 21 mechanical keys (gateron blues which are pin-compatible clones of Cherry MX switches) with variable brightness white LED backlight on each key.
  • In addition to the 17 standard keys of a numerical keypad, there is also a row of four keys across the top of the device which are programmable macros. (Well, all keys can be programmable macros, but this is how I have configured jank.)

The schematic and PCB layout were designed in KiCAD. The schematic can be divided into five main areas/components:

  1. The key matrix - 21 gateron mechanical keyswitches connected in a matrix of 4 columns and 6 rows. The key switches each include a 3mm LED.
  2. ATmega32u4 AVR microcontroller - Selected because it has enough GPIO and hardware USB. I'm also familiar with the device from previous projects and have a few on-hand. Includes an external 16MHz crystal.
  3. MP3202 LED driver - I've not (successfully) used a boost LED driver before, so this was a neat learning experience. It drives all 21 keyswitch LEDs and is enabled by a PWM signal from the AVR which allows variable LED brightness.
  4. USB type-C Receptacle - Configured to be detected by a host as a USB 2.0 device. I went with a simple 16-pin through-hole connector that is (barely) hand-solderable.
  5. 6-Pin AVR ISP connector - A standard In-System Programming port.

The firmware can be separated into four parts:

  1. USB HID Implementation - Achieved by using Dean Camera's LUFA Library.
  2. Key Scanning - By sequentially enabling each row of the key matrix, then reading the state of each column, key scan functions determine which keys are pressed. The table below details the keyswitch layout and the corresponding row and column as connected to the microcontroller.
  3. Macro "typing" - The LUFA library made it easy to send regular keystrokes but I had to write some functions that would send a series of sequential keystrokes (i.e. to emulate typing).
  4. LED Control - Uses a timer configured as a PWM signal output on a pin connected to the LED controller enable pin. A tact-switch push-button on a pin-change interrupt is configured to cycle through various LED modes. The modes include various levels of brightness and a few pulsing effects. A second internal timer is used to vary the PWM duty cycle to provide the pulse effects.

  • 1 × atmega32u4 Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers
  • 1 × MP3202 Discrete Semiconductors / Power Transistors and MOSFETs
  • 1 × USB-C Receptacle
  • 1 × 16 MHz Crystal
  • 1 × Tact-Switch

View all 14 components

  • Submission for 2021 HaD Price: Challenge 02C: Refresh Work-From-Home Life

    clewsy06/18/2021 at 04:52 0 comments

    Jomie suggested this project could be a valid submission for the contest, so here goes!

    This could definitely be a useful addition for someone that transitioned to working-from-home with a laptop or a keyboard with no number pad.

    The macros could also make things a bit nicer.  Personally I frequently use keys configured as media controllers - it's much faster and nicer than hunting for the right Fn+F# key combination.

View project log

Enjoy this project?



Jibril wrote 06/10/2021 at 11:47 point


  Are you sure? yes | no

clewsy wrote 06/10/2021 at 22:52 point


  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates