Introduction: My First Handwired Keyboard With Analog Controlled RGB Underglow

This is a project I always wanted to complete for a while as I always was into creating custom keyboards. I looked for ideas of how I could work with Arduino to create my own keyboard as I know that certain Arduinos have a specific driver that can run keyboard properties. As I found out I could create a keyboard from scratch with much time spent through soldering I was up for the task. I had some RGB strips lying around and I attempted to implement a controllable RGB under glow with some 555 timers to spruce up this DIY project. My keyboard follows the preonic ortholinear layout which I layered keymaps on top of each other which I can switch between with buttons on the keyboard. This is so I can still have the nearly the same functionality of a regular 100% keyboard on something as small as this.

Special thanks to these other projects I have taken inspiration off of:

RGB Dimmer Circuit

Hand wiring Project

Supplies

Keyboard Parts:

  • Arduino with the ATmega32U4 datasheet (Needed to compile the specific keyboard drivers). I used the Arduino Micro (Pro Micro and Leonardo are also other common Arduino that has this datasheet).

Price: $22.80 (Arduino Pro Micro)

  • x58 1U Keycaps (Could use letters, I used DSA blank keycaps and colour coded the project as shown in the pictures. The 1U is a regular sized keycap).

Price: $3.50 (Per 10 keys)

  • x1 2U Keycap (This is for the spacebar, could use 2 regular size keycaps but you would require 1 more switch as it would be 60 keys total.2U takes up 2 1U keycap space on the keyboard).

Price: $2.00

  • x59 Switches (Can use any switches, use the same one for all keys). The ones I used are called Gateron Milky Yellow switches. Keep in mind that the optional lube changes corresponding to the type of switches used. In this case, my switches are linear switches. Other switches types include tactile and clicky).

Price: $4.00 (Per 10 Switches)

  • x59 1N4148 Diodes (Needed to keep the flow of current of a column in one direction, need 1 for every switch used)

Price: $16.99 (Comes in a pack of 500)

  • x1 Plate mounted stabilizer (This is for the spacebar key in order for it to be kept in place and properly input a signal when pressed).

Price: $5.90 (Bundled with a 6.25U stabilizer)

  • Plate material (This is for the keyboard casing. I used specifically 1.5 mm thickness material as I found it to be perfect to settle the switches firmly on their designated spots. Dimensions depend on the dimensions you want to build your keyboard. Mine is 6 by 12 layout).

Price: $15 (Wood sheets, comes in a pack of 6)

  • Standoffs I used to elevate the keyboard to fit everything snug between the top and bottom plates of the casing. (I used M3 screws, can use other screw sizes but standoffs must correspond to the size)

Price: $18.99 (Often comes in large packs of different sizes)

  • Jumper Wires
  • *Optional* Kryton 205g0 Switch Lube (Makes the switch sounds more clean. Does not have to be from Kryton but should have 205g0 properties for the switches)

Price: $19.99 (Comes with other useful keyboard tools)


RGB Light Control:

  • RGB Strip (I used a 5V to use the Arduino to power it)

Price: $16.39 (4m)

  • x3 10k Potentiometers

Price: $1.05

  • x6 diodes (1N4004 are the ones I used, 1N4148 are also viable). Price is stated previously.
  • x6 100 nF Capacitors

Price: $0.08

  • x3 5.1k ohm resistors

Price: $0.43

  • x3 555 timers

Price: $1.05

  • x3 NPN transistors

Price: $0.61

  • Jumper Wires


Recommended Tools:

  • Wire Stripper + Pliers
  • Soldering Iron + wire
  • Glue Gun
  • Laser Cutter (Can purchase CAD casing online or cut at a local CAD retail)

Step 1: Knowing the Matrix

Keyboards have a specific way of communication which is extremely important to understand when developing your own custom layout. Switches send signals to the microcontroller in which each pin input access a part of the code to output the specific signal the switch sends. The easiest way of creating these circuits is to directly wire the individual switch to a designated input pin. The problem with that is that larger keyboards would have switches that outnumber the amount of pins on a microcontroller, hence the keyboard matrix.

This matrix sends signals in terms of rows and columns, where each number of rows and columns are instead connected to individual pins. Here, the input from the switches send 2 signals from their row and column which works like a coordinate map. For my keyboard layout, I have a 5 by 12, 5 rows and 12 columns. In total, the amount of pins that this layout would use is 17 (5 rows + 12 columns). This drastically decreases the amount of pins needed from 59 total keys --> 59 pins to 17 pins. For even larger layouts it is best to keep in mind how many addressable pins are on the microcontroller you are using to prevent the case where the amount of rows and columns on the keyboard outnumber the pins. Finally, with the knowledge of the matrix, you can start creating your keyboard layout.

For the CAD developing software I am using, I needed to have raw data of the keyboard layout that I am using. I used the website, Keyboard Layout Editor which can edit a keyboard layout design for you. It doesn't matter what keys are displayed as long as the overall layout corresponds to the position of each key is. Once you are done, keep a copy of the raw data found in one of tabs on the editor.

Step 2: Creating the Keyboard Casing

The first step to creating this DIY keyboard is to develop the casing for it. With this online builder, we can input a plate layout and adjust settings in accordance to the materials we use to develop the CAD files for the casing. The layout comes from the previous step where we copy and paste the raw data into the plate layout section. For the case type, I made a sandwich design with 10 mount holes with M3 diameter. I selected the bottom and top layer CAD files as I didn't need the other pieces as I had standoffs to connect them. From there, I laser cut them onto the 1.5 mm thick wood sheets I had.

Step 3: Putting the Switches and RGB Strip Onto the Casing

Before this step, the optional step of lubing your switches come first. I referred to this guide when I did it. The casing itself should be able to hold the switches firmly so make sure the switches are upright (I used the Gateron logo on the switch to reference. The 2 pins on the back should be horizontal from each other and is on the upper half). After putting the switches on, you can start with the soldering or also put on the keycaps. (I found it easier when putting on the keycaps as it made the keyboard more flat when I soldered).

Next was the bottom layer. For the backlit I had RGB strips that included an adhesive. I cut off the RGB strips at the soldering points and stuck them onto the bottom layer which I then soldered the lines together after.

Step 4: Soldering Time

Next is one of the tedious parts of the project, the soldering of the columns and rows of the switches. First, I soldered the rows as it involves the diodes in this case. First I bent the wire line furthest from the black line on the diode to create a loop that makes it easier to solder onto the leftmost switch pin. The excess wire after creating the small loop can be cut off for cleanness. Then I bent the wire near the black line on the diode to the direction facing the next switch to the right on the keyboard. From there u nest the diode onto the switch by putting the loop over the leftmost switch pin. Repeat that step for every switch until all the switches have their own individual diodes. Next are the columns. There are many ways to wire up the columns, but the strategy I used was stripping jumper wires to create exposed wire on the points where I would need to solder. From there, you can start soldering on the the rightmost pin for each column of switches. Make sure to have the sheath covering the wire especially when overlapping the row wires from the diodes to prevent any current passing onto the separate lines. Once you are done, the back of the keyboard should look similar to the picture above.

Step 5: Soldering the Microcontroller

First thing before attempting to incorporate the microcontroller into the build, is to remove the header male pins that came with the Arduino in the first place. This is done by first removing the plastic casings on the pins with a wire cutter before attempting to desolder. Next we desolder the pins through using a soldering iron. A little tip I have when desoldering header pins on microcontrollers is to add a little solder wire to the soldered areas which makes it easier to pull the pins out.

Once all of the pins are removed, we should next keep note of where we are routing our wires. Keep note of which row/column is connected to which input pin as it is very important when approaching the firmware process. From there, we can start soldering the wires from the microcontroller to the rows and columns. It doesn't matter where you solder the wires on the lines, but make sure each row and column has one line connecting to one pin on the Arduino. I found this the most difficult step, but one tip I have when completing this part is to solder the rows and columns nearest to where you want your microcontroller to sit, then work towards the further ones. Remember to also add a power and ground wire to the Arduino if you would like to create the analog RGB control for the backlit effect.

Step 6: Flashing the Firmware

Finally, when everything is wired up, you can start the process of flashing the keyboard firmware onto your keyboard. Here you would need to install the QMK toolbox for Windows and Mac in order to compile the keyboard code onto the Arduino safely. I used the Keyboard Firmware Builder online to develop the code and custom layers for each of the keys on the keyboard.

On the website, refer back to the raw data you had when you created the CAD plates for the keyboard. You would need the same collection of text to import the layout onto the website. From there, we can check over the wiring on the wiring tab. Then the next step is to deal with the pins.

The controller on the keyboard is run by the ATmega32U4 datasheet installed on the Arduino chip. The row and column pins are different from what the Arduino has on the printed pinout guides on the microcontroller. If you refer to the pinout diagram in the picture above, the port pin section has the pin codes corresponding to each pin listed. With this data, select each of the pin codes corresponding to each of the pins on the microcontroller that is connected to the specific row or column to generate the first part of the code.

Next is the keymap. Here is where you can design each individual key input to your own preference. The layering aspect can be edited as well through the selection of QMK functions on the website. You can select different layers to modify and include a layer switch button to switch between the layers of keys you placed on the layout. You can refer to my layout with the file attached, or the pictures of my layout above.

Finally, you can name your layout and download the Hex code to compile on the QMK toolbox. You first, select the hex file in the directory, then you flash your microcontroller by pressing the reset button on the microcontroller. Hit flash on the QMK toolbox and if the flash is completed, you can test the keyboard with the key tester that is also on the QMK toolbox. Check if every key works and corresponds to what you designed on the firmware.

In cases where the keys aren't working or malfunctioning, here is what you would want to check if you run into these situations.

  • Check if the row and column lines are connected
  • Check if there are any points on the matrix that could disrupt current
  • Check if there are any wires laying directly on the switch pins
  • Revise the pinout diagram if you put the wrong pin code into the firmware builder
  • Check if the wiring you set on the firmware builder corresponds to your actual wiring.

Step 7: The Backlit RGB Circuit

With the keyboard portion completed, the second part to the project won't be as hard. Here I wired up my analog circuit that controls the red, green, and blue brightness on the strips. I used potentiometers and 555 timers to accomplish this task. Refer to pictures above to learn the wiring of the circuit. Once the wiring of the circuit is done, the power and ground wires from the Arduino can be connected and the RGB Strip can connect its power wire (Black wire) to the power row on the breadboard, the RGB wires individually go to one collector line of 1 of the 3 transistors on the circuit. From there you can test the circuit after plugging in the Arduino.

Step 8: Results

With Step 7 completed, you have finished making your own hand wired keyboard with a small spice up with the controllable backlit RGB light. Now you can enjoy playing with your creation, show it off to your friends, or just pat yourself on the back for the fun tedious work you went through when completing the project.