A macropad is a small keyboard that plugs into your PC and has custom buttons you can program yourself. As a Christmas present for a friend who tutors online, I decided to make my own macropad with each key featuring a mathematical symbol.
When tutoring online, and trying to type math equations, you usually end up having to write symbols in English, or use complicated Alt codes - typing Alt-251 in your keyboard types '√'. This can be time-consuming and inaccurate, while giving you something else you need to remember. For most people, a keyboard with math symbols is a product they wish they could have, but with some switches, some engineering, and an Arduino, it is.
This is an early sketch-up of what I imagined the macropad to look like. I planned on 3D printing the keycaps, so if at any time they decided they wanted a different key combination - maybe because they needed a new symbol - a new keycap could be printed in 10 minutes. I also wanted code that was hotswappable - only one part of the code should have to be changed for a new key binding, and the change in the binding must not require having the Ardunio IDE installed.
Most keyboards use complicated matrices to require fewer microcontroller pins for a large number of keys - a 10x11 keyboard would only require 10+11=21 pins instead of the 110 pins that would be needed if each key were wired up separately to the chip. In my case, however, I only have 9 keys, so only 10 pins are needed in total - 9 digital input pins for each switch and 1 common ground. The Arduino Pro Micro has these 10 pins, and also has the ATmega3SU4 chip, which can emulate a keyboard device for Windows and macOS devices. This means no fancy serial-reading Python script needed to be installed on the computer for the macropad to work.
The macropad would communicate to the PC via the Arduino's built-in USB-C port. The whole project required 3D modelling and printing to get the custom parts needed for the build. The coding was relatively simple for a macropad with so much functionality. I wanted this to be as customisable as possible - if the key commands were set in stone, I might as well have bought a pre-built macropad for 10 times the cost.
Each switch was wired up to a different digital pin, as shown in the diagram above, although it turned out that my board only had 8 digital pins, so I needed to use one of the analogue pins to connect all 9 keys. The code would make the Arduino set a certain low voltage across each pin and ground. When the key is pressed, the internal resistor would detect a small change in voltage and current in the corresponding pin. The code then assigned this pin to a specific key and told the computer that it had been pressed.

An interesting point to note is that I used function keys that aren't available on standard keyboards. Most keyboards go up to F12, so I assigned each of the nine keys from F13 to F21. This would mean that you would still have full functionality of your standard 12 function keys. The Arduino would emulate a keyboard, pressing one of the F13-F21 keys, and then a program on the computer, called AutoHotKey, would translate this into a Unicode symbol, such as '√'.
The code for the Arduino is below:
And the code for AutoHotKey is below:
; squareroot
F17::Send, {U+0x221A}
; pi
F14::Send, {U+0x03C0}
; cube root
F16::Send, {U+0x221B}
; sigma
F18::Send, {U+0x03A3}
; integral
F21::Send, {U+0x222B}
; delta
F19::Send, {U+0x0394}
; cube
F20::Send, {U+0x00B3}
; squared
F13::Send, {U+0x00B2}
; powerofN
F15::Send, {U+0x207F}
The symbol printed when a button is pressed can easily be changed by changing the Unicode code point ({U+0xXXXX}), and the key will then print a different symbol, as long as it is in the list of Unicode characters in the UTF-8 encoding.
After printing the parts, I pressed the switches in, ensuring their orientation was correct so that the keys would be slightly angled towards the user for ergonomic purposes.I then soldered up the common ground, known as a ground bus, so that one leg from each switch was wired up to the same ground, which could then be soldered up to the Arduino
A wire was then soldered up to each of the remaining pins, which was by far the most difficult step of this project. I randomly assigned each switch to a digital/analogue pin on the Arduino, since at this stage, it didn't matter what the connection order of the switch to the board was, as that could be adjusted in software. I then designed 3D-printable keycaps, using the text tool in Onshape to 'indent' them so that the symbols required would be easily traceable with a black pen. These could then just be pressed onto the switch securely.
I then designed and printed the base to fit seamlessly with the top half, including a small hole to allow a USB-C cable to leave, allowing connectivity with a computer. The walls were printed with no infill, and some extra code was written so that the Arduino could use its onboard light as an internal backlight, allowing the light to seep through the plastic and diffuse. The finished product was then screwed together, with hot glue stopping the USB cable from being ripped out of the back, making the product as reliable and resistant to impact as possible.
The Arduino cost £4.25, the switches £2.35, the wires £0.20, and the cost of 3D printing filament, not including the many failed trials, was £0.15, leading to a total project cost of £6.95. The Onshape files are linked below:
https://cad.onshape.com/documents/e7c20172965a4f680537ca73/w/18755b486bad01712a124736/e/699d42f7f6445a4cf280a8f5?renderMode=0&uiState=6918add084cd871d5b1b9af2











