Taking Shortcuts

Leonardo-Based Macropad

Nicolas Mason

Issue 53, December 2021

How to use an Arduino Leonardo to make a three-button macropad with basic multimedia controls.

Recently in issue 49, we described a Raspberry Pi Zero W Powered Macro Keyboard using a Keybow MINI (3-key) kit from Pimoroni. This month, we were contacted by a local maker who made a similar macropad using a tiny Leonardo board. We caught up with Nicolas to find out more.

Thanks for sharing your macropad project with us, Nicolas. Firstly, please tell our readers about yourself and what got you started in electronics.

I’m 29 years old and live in Sydney. For as long as I can remember I’ve been obsessed with figuring out how things worked. Growing up, my constant curiosity led me to reading lots of non-fiction books. Despite my parent’s insistence on having me reading fiction books for school, I always ended up with my nose in some kind of electronics book. Despite my lack of understanding of the greater field, I persisted in trying to make sense of what made electronics tick.

My experience with electronics projects came and went in waves for such a long time. From first picking up a soldering iron in high school, then building a piezo microphone for university, and finally making the leap with Arduino and Raspberry Pi in recent years.

Over the years I developed a knack for all things technical which has culminated in my current vocation as a Master Control Room operator for a television playout facility. On the side, I noticed I amassed a collection of loose components that were gifted to me by my former colleagues, some of whom were very big on ordering far too many components from Aliexpress. During the recent Sydney lockdown I decided to finally put all my electronics reading into practice.

Lockdown certainly provided the time for people to pursue interests they wouldn’t normally do. What was the motivation for building your project?

The idea for the macropad first came to mind as I streamlined my home computer setup with a slick tenkeyless (a reduced sized keyboard with no number pad) mechanical keyboard, originally purchased to help with my post-graduate studies at the time. While the keyboard itself was fantastic with my papers, I found myself missing the multimedia controls that I often used with my music players.

After a bit of trawling on Reddit (r/mechanicalkeyboards) I discovered these bespoke keypads that were programmed for specific system functions beyond text input. It was at this point I decided that such a project was something I could try my hand at.

Parts Required:JaycarAltronicsPakronics
1 × Leonardo Mini or EquivalentXC4431-DF-DFR0282
3 x SPST Snap Action Keyboard SwitchSP0721S1096-
1 x PerfboardHP9552
Hookup and solid core wire required

Parts Required:

How does it work, and could it be used for other applications other than for multimedia controls?

The macro-pad is driven by a miniaturised Leonardo board that I chose on its capabilities as a HID device. This specific board from Jaycar only has three digital and three analogue pins broken out but I was drawn to its minuscule footprint.

It is matched with three PCB mounted SPST snap action keyboard switches. No CherryMX’s here however, that’s not to say that it couldn’t be adapted to accommodate them in a future revision.

The code used is an extended form of keyboard library (HID-Project by NicoHood) and so can be adapted for other applications but substituting the commands for keyboard combinations depending on the application e.g. (Alt+V/M/A for Zoom).

We do like the small form factor compared to the full size Leonardo board. Were there any design challenges you needed to overcome?

The small nature of the project ended up being the biggest challenge with the project as my oversized hands made wiring up the board quite cumbersome. This was overcome through the use of a “third hand” magnifier rig. To complement this challenge, it was my first project that used proper veroboard instead of the breadboard-style protoboard that I felt was constrained by the shared tracks. Ironically I ended up using solid wire to create the ground plane for the switches too.

Do you plan to have it installed in an enclosure?

The decision to keep it “naked” was a conscious one, growing up in the late 90’s/00’s that exposed electronics look was an aesthetic that I could appreciate. That being said, I would like to learn how to 3D-print and may have an enclosure for it sometime in the future.

Having the electronics exposed is a constant reminder of your electronics prowess we say, as long as you don’t short anything out. What operating system is it designed for or can it run on multiple OS?

In its present state, the macropad is application and OS agnostic due to the HID-Project Arduino library. This library include the embedded multimedia control codes that any PC regardless of OS would recognise. I need to give a shoutout to r/Arduino for pointing me in the direction of this fantastic library. Otherwise, my macropad would have only ever been an extended set of function keys that would still need to be mapped in the host OS.

#include "HID-Project.h"
const int pinLed = LED_BUILTIN; //Built-in LED for confidence monitoring
const int pinBut1 = 9; //Mute
const int pinBut2 = 10; //Play/Pause
const int pinBut3 = 11; //Next Track
void setup() {
  pinMode(pinLed, OUTPUT);
  pinMode(pinBut1, INPUT_PULLUP);
  pinMode(pinBut2, INPUT_PULLUP);
  pinMode(pinBut3, INPUT_PULLUP);
Consumer.begin(); //Multimedia controls live within this function
void loop() {
  if (!digitalRead(pinBut1)) {
    digitalWrite(pinLed, HIGH);
    digitalWrite(pinLed, LOW);
  if (!digitalRead(pinBut2)) {
    digitalWrite(pinLed, HIGH);
    digitalWrite(pinLed, LOW);
  if (!digitalRead(pinBut3)) {
    digitalWrite(pinLed, HIGH);
    digitalWrite(pinLed, LOW);

It’s great that the maker community is willing to share knowledge. Tell us more about the code, and will you make it available to our readers?

The code for this project was arguably the simplest aspect of this project. I ended up using the “Consumer” example file from the HID-Project library to act as the basis for the macropad. On the breadboard I tested the single button with all the intended functions of the project (audio mute, play/pause and next track). From there I then expanded the functions to all three available pins. This code will be available on my Hackaday.io page. https://hackaday.io/project/182268-umacropad

Excellent. We’ve also taken the liberty to provide your schematic here for any of our readers keen to make one for themselves. What are you working on next?

I’m currently working on a minimal UNO-based watch that’s about to make the jump from an UNO board to a raw ATmega328 on a breadboard.

Interesting. We look forward to hearing more about that in the future. Thanks again, Nicolas.