Introduction: Key-Macro

About: I am a professor in the Faculty of Sciences of the National Autonomous University of Mexico. My hobby is designing devices with Arduino.

This project consists of an auxiliary eight key keyboard that sends macros (text strings) to the computer. Up to 64 macros can be previously stored in a text file saved in a microSD card. These macros are organized in eight pages which can be selected with a keys combination.

One of the 3D printed parts of this project is based on:

0.96" 128x64 OLED Snapfit case by TAz00, licensed under the Creative Commons -Attribution license.

Step 1: Components:

    You will need the following:

  • Pro Micro Leonardo Atmega32u4 Arduino.
  • Oled Display Module Ssd1306 0.96” 128 × 64.
  • Micro Sd Card Reader.
  • TTP226 Capacitive Touch Sensor Module.
  • 2× Push Button Micro Switch 6 × 6 × 9 mm
  • 3D printed case (4 parts).

Step 2: Wiring

Connect the pins of the components to Arduino as follows:

  1. Push Buttons:
    • SEL to Arduino GND and A2
    • RES to Arduino GND and RST
  2. SD Reader:
    • CS to Arduino D10
    • MISO to Arduino D14
    • SCK to Arduino D15
    • MOSI to Arduino D16
    • Vcc to Arduino Vcc
    • GND to Arduino GND
  3. Touch Sensor Module:
    • From OUT 8 to 1 to Arduino D4, D5, D6, D7, D8, D9, A1, A0 (in this sequence).
    • Vcc to Arduino Vcc
    • GND to Arduino GND
  4. OLED Display:
    • SDA to Arduino D2
    • SCL to Arduino D3
    • Vcc to Arduino Vcc
    • GND to Arduino GND

I recommend following this sequence to solder the components. This makes the wiring process easier.

Step 3: Assembling

Once all the components are wired, fit and glue the push buttons into place, as well as the touch-sensor module and the Arduino to the 3D-printed base. Then, do the same with the keyboard cover and fit the MicroSD reader and its cover to the same piece. Finally, fit and glue the OLED display to the lid and glue it to the keyboard cover.

Step 4: The Arduino Sketch

The sketch works with English keyboards. The Spanish version will be available soon!

Step 5: The Macros Text File

The file with the macros (macros.txt) must be stored in the MicroSD card and organized as follows:


The names of macros and pages are optional and only appears in the OLED display to identify these. If you omit the macro name, the first characters of it will appear.

You can download the macros.txt file as an example of common macros for LaTeX, Arduino, C, and Python.

Step 6: How to Use the KeyMacro:

Connect the Key-Macro to the USB port of the computer using a micro USB cable. The computer will recognize it as a keyboard. Press the Select button of the Key-Macro and wait until the screen is updated, then press a page number on the touch keyboard. The list of macros in the selected page will appear on the display. Press a number on the touch keyboard and the Key-Macro will send the string to the computer. To change the macros page, press the Select button followed by the number of the desired page.



    • Tiny Home Contest

      Tiny Home Contest
    • Metalworking Contest

      Metalworking Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    10 Discussions


    5 months ago

    Very nice project Raul7321.

    I will build something similar in the next days. But I'm going to take a keypad. But my thinking was exactly like your project.

    Also I will included a rotary encoder as subjected by throbscottle.

    Continue posting things.

    1 reply

    Thanks! please Let me know if I can help you!


    5 months ago

    Can the macros control mouse feactures like move to a certin spot and press left or right as well as the mouse wheel?

    1 reply

    Hi! This version of the sketch can't do it, but the hardware could. It's a good idea to include in the next version!

    Nice project. It reminds me a bit of the "jog dial" that was on a Viao I once had. Handy little thing.

    Maybe you could consider doing a version that features a rotary encoder...

    1 reply

    The project looks great! That 3D printed enclosure for it is so clean and professional looking :)

    1 reply