Arduino Pro Micro Keyboard



  1. Arduino Pro Micro Virtual Keyboard
  2. Arduino Pro Micro Mechanical Keyboard
  3. Arduino Pro Micro Bluetooth

The Micro board is similar to the Arduino Leonardo in that the ATmega32U4 has built-in USB communication, eliminating the need for a secondary processor. This allows the Micro to appear to a connected computer as a mouse and keyboard, in addition to a virtual (CDC) serial / COM port. Communication between the PC and the Arduino Pro Micro happens through the USB, unlike the Arduino Uno and Mega, which use the RX and TX lines. In your case, the USB pins of the Micro are used to communicate with the PC. Hence, the RX and TX pins are available for digital input and output operations. You need the following components: Arduino Leonardo board. Micro USB cable.

How you upload the firmware to your Arduino, depends on your computer’s operating system. As I prefer to work with macOS, this guide uses tools and commands that work fine on a current High Sierra v10.13 machine.

USB Cable

You need a Micro-USB cable to connect the Arduino Pro Micro. The cable is required for uploading a new firmware and using the keyboard afterward. You can just order any ordinary cable from the Shopping List, or look for a vendor that makes awesome-looking custom cables.

Do you work for a company that offers custom USB cables and you can provide a discount code? I would love to feature your business and services here! Please let me know.

If you use the Shrink Kit, you can use already use the Mini-USB cable to flash the Arduino. The connection works for using the keyboard, as well as uploading a new firmware to it.

Dependencies

To flash your Arduino with software, and for compiling the firmware, you must install a few tools like avr-gcc and avrdude. Both are available on Homebrew, but I recommend the CrossPack by ObDev.

CrossPack for AVR

DMG, 42 MB

CrossPack for AVR Development is distributed under the terms of the GNU General Public License version 2, except AVR Libc which is distributed under a more liberal license. See the manual for the full text of these licenses.

Firmware

The firmware is based on QMK and customized to work with the Arduino Pro Micro on the board. All sources for the keyboard are available on GitHub using the GPL v2 license.

The repository already includes a default keyboard configuration that you can use right away available in the keymap.c file. The file is located in the keyboards/68keys folder.

Basically, I only moved ESC to the right side. Thanks to QMK, you can easily add additional layers and replace Caps Lock for example with FN. Holding FN could enable a second keyboard layer, which includes media controls.

Compile your Firmware

After you have installed all needed dependencies, compile the firmware with your custom keyboard layout:

When the command finishes without errors, you end up with a few 68Keys.* files in the .build folder. In the next step you will upload the firmware to your Arduino board.

Upload Firmware

Connect the Micro-USB cable to your Arduino Pro Micro and your computer. The board should be listed using ls /dev/tty.* . If you cannot find your board, first check if the green light on the Arduino is on.

If your computer detected the Arduino board correctly, it’s time to upload your custom firmware to it.

On some systems, the number following usbmodem increases every time you re-connect the board. On others, it stays the same or just switches to a different number when the Bootloader is enabled. Just run ls /dev/tty.* after you connected the board or enabled the Bootloader to figure this out.

After you hit enter you will see a prompt to reset your controller. You can use the Push Button to enter the Bootload on your Arduino. Press it twice directly after re-connecting the board to your computer and the process to flash the firmware to the board will start automatically.

Make sure everything works

You can install lsusb using Homebrew to list all connected USB devices. If you uploaded the firmware to the Arduino, you computer should list the keyboard with its name.

Finish the Sandwich Case

After the successful upload of your firmware, you should finally be able to use the keyboard after re-connecting it to your computer. If everything works as expected, it’s time to close the Sandwich Case and you’re done!

Make sure the Micro-USB cable is connected to the Arduino board and use the M3 Screws and Standoffs to close the Sandwich Case.

Thanks!

Woow, that was a ride! Thanks for reading this guide, I hope you enjoyed building your new mechanical keyboard. I would love to hear your feedback and see the results of your work, please share them on twitter. What key caps did you use for your keyboard? The SA Grade set is a perfect match! 😍

So you want to build your own keyboard (or keyboard-like device), but you are not sure what to use for the brains and how to connect and program it? I will describe what I came up with for the #Alpen Clack keyboard.

The ATmega32u4 microcontroller is an excellent choice for any HID device, such a mouse, a joystick or a keyboard. That's mostly because it has hardware USB support, so you don't have to muck about with unreliable and hacky bit-banged VUSB. There are three popular boards with that microcontroller: Arduino Leonardo, Teensy 2.0, and Pro Micro (not to be confused with Pro Mini, which uses ATmega328). Arduino Leonardo is too big for our needs. Teensy 2.0 is quite expensive. Pro Micro can be had for about $4 in singles from the usual oriental sources. Sounds like a winner. Let's look at the pinout:

According to this diagram, we have 18 usable pins. An 18-key keyboard is not very useful. Can we somehow connect more keys? Turns out we can, by using a key matrix. We basically make rows and columns, and put switches on the crossings. Then we scan that repeatedly to figure out which ones are pressed. We add diodes, so that the pressed keys won't interfere with each other. Simple.

So, with 18 pins, the largest matrix we can get is a square 9×9. That's 81 keys. Hmm, that may be fine for those tiny, chocolate bar keyboards, but a modern PC keyboard has 105 keys. Even if we ditch the keypad, like I did in my keyboard, that only removes 17 keys. We are still 7 keys short!

Wait, what does it say about LEDs at the bottom there? Two more independent pins? Great, we only have to remove the two resistors and solder wires in their place, and we have 20 pins for our disposal. That gives us the largest matrix of 10×10, so 100 keys. Still not enough for the full layout, but should be fine for a tenkeyless keyboard.

Next, programming the thing. After a short search, I found the TMK Keyboard firmware, which is just perfect for our needs. All we need to do is to copy the 'onekey' example keyboard, and modify the config.h, keymap.c and matrix.c files to fit our keyboard.

In config.h, we have to set the correct number of rows and columns. I used 8 columns and 11 rows in my keyboard, which gave me the 88 keys I needed (actually 87). You can also change some other options here and in the Makefile.

Next, the hard part -- matrix.c. You will need to define four functions: init_cols, read_cols, unselect_rows and select_row. You can look at all the examples included in the repository to get an idea what they need to do. Basically, init_cols sets all the column pins in INPUT mode with internal pull-up resistors. It's called once at the start. Next, the read_cols function reads the state of all those column pins, and reports it as a single byte (or more, if you have more than 8 columns, but see below). The unselect_rows function sets all the row pins to floating, and finally the select_row function sets the specified row pin to low. That's it.

Arduino Pro Micro Virtual Keyboard

One note about having more than 8 columns: while the code looks like it should support it, I didn't manage to get that to work. I'm not too worried, because I only needed 8 in the end, but if you need more, you will probably need to copy the matrix_scan function from one of the larger examples to get it to work.

Lastly, you need to define the key map -- basically to tell the firmware which key is which. You do that in keymap.c, by defining an array of arrays of arrays... I mean, an array of layers, each layer being an array of rows, each row being an array of columns, each column being an array of keys. The layers let you setup cool effects with special keys and such, see the keymap documentation for details.

Lastly, we need to modify the Makefile for our board. I used Makefile.pjrc, because the default one doesn't support N-key rollover yet. Set the following variables:

Diy keyboard arduino pro microNow you are ready to program your board. Connect a switch between the GND and RST pins, connect the board to USB and press the switch two times quickly. That puts the board into programming mode. Now run 'make -f Makefile.pjrc program', and it should compile and burn the firmware to your board. After that it will be visible in 'lsusb' command as whatever ID you set in the

Arduino Pro Micro Mechanical Keyboard

config.h

Arduino Pro Micro Bluetooth

file, and shorting any row pin with any column pin should produce key presses. Now you can solder the board into your matrix, and you are done.