Arduino Uncategorized

Programming Macros for Ergodox

The default configuration tool on Input Club or Massdrop don’t allow for macro programming. So you will have to get your hands dirty and mess with the firmware code a little. It’s not hard.

  1. Run the following commands on your terminal to clone Ben Blazak’s firmware code from github and create a custom layout for yourself
              git clone
              cd ergodox-firmware
              # Macros are supported in his partial re-write branch 
              git checkout partial-rewrite
              cp firmware/keyboard/ergodox/layouts/qwerty--ben.c firmware/keyboard/ergodox/layouts/qwerty--custom.c
  2. Open keyboard/ergodox/ and add qwerty–custom to the KEYBOARD_LAYOUTS and change the KEYBOARD_LAYOUT to qwerty–custom. The keyboard layout will look something like this :

    KEYBOARD_LAYOUT := qwerty--custom
    # default layout for this keyboard
        test \
        arensito--ben \
        qwerty--ben \
        qwerty--custom \
        colemak--kinesis-mod \
        dvorak--kinesis-mod \
  3. Edit keyboard/ergodox/layout/fragments/macros.part.h and create a function for your macro. As an example, we will do a macro that prints b4.

    // Define a constant for the keys
    #define K_4 0x5C   // 4
    #define K_b 0x05   // b
    // Our macro's name is m_b4
    void keys__press__m_b4(void) {
        // Press and release b
        usb__kb__set_key(true, K_b);
        usb__kb__set_key(false, K_b);
        // Press and release 4
        usb__kb__set_key(true, K_4);
        usb__kb__set_key(false, K_4);
    // Do this for all your macro functions
    void R(m_copy)(void) {}
  4. Now that the macro is ready, it can be placed in the layout. Put m_b4 for whichever key you want the macro to trigger. Edit firmware/keyboard/ergodox/layouts/qwerty–custom.c and put your macro in it.

        MATRIX_LAYER(  // layer 2 : symbols and function keys
    // macro, unused,
           K,    nop,
    // left hand ...... ......... ......... ......... ......... ......... .........
      lpo2l2,       F1,       F2,       F3,       F4,       F5,      F11,
      transp,   braceL,   braceR,    brktL,    brktR,      nop,   lpo2l2,
      transp,  semicol,    slash,     dash,        0,    colon,
      transp,        6,        7,        8,        9,     plus, lpupo3l3,
      transp,   transp,   transp,   transp,   transp,
                                                                  transp,     m_b4,
                                                        transp,   transp,   transp,
                                                        transp,   transp,   transp,
    // right hand ..... ......... ......... ......... ......... ......... .........
                   F6,       F7,       F8,       F9,       F10,      F11,      F12,
                lpo2l2,    caret,  undersc, lessThan, grtrThan,   dollar,  volumeU,
                         bkslash,        1,   parenL,   parenR,    equal,  volumeD,
              lpupo3l3, asterisk,        2,        3,        4,        5,     mute,
                                    transp,   transp,   transp,   transp,   power,
      transp,   transp,
      transp,   transp,   transp,
      transp,   transp,   transp  ),
  5. In the terminal, run make It will create firmware.hex
    Upload the file to Ergodox and your macro will be ready for use.

You can look up the hex codes for keys here:


The new light sensor

In my last post, I spoke about creating a light sensing “widget” that I could attach to my projects. I used a 10k resistor and was reading the light readings off of the analog pin on Arduino. However, I noticed that attaching an LED to the circuit was throwing the readings way off.

so, I found another way of calculating brightness. I found this article which talked about using a capacitor attached to the photocell which is in turned attached to a digital pin on Arduino. I was able to attach an LED without throwing off my readings a lot. While I was making these modifications, I also decided to make some other improvements (like getting an LED holder to hold my power indicator)

Here’s a pic:

The new light sensor

If you guys are looking for an informative tutorial on how to use a photocell, I found this article very helpful: