Return to Level1Techs.com

78 key 6.6 inch USB keyboard

There have been other attempts at building compact USB keyboards. Most of them lack certain features I would like such as NKRO, function keys, multimedia keys, etc… Having no background in electrical engineering, I decided to build a keyboard.

As a base I will be using the ATmega32U4 microcontroller. This is the schematic I built for the PCB layout. From what I understand keyboards are created using a matrix assigning pairs of pins to a specific key-press. I will be using 19 pins for 78 keys. The diodes are necessary for NKRO as they keep the current moving in one direction.

Next I wired all the traces for the PCB and generated the Gerber files. Although there are only 78 keys, I plan to have it function as a tenkeyless keyboard assigning the rest of the keys and multimedia functions in a separate layer when FN is pressed.

I’m currently waiting on the PCB fabrication and parts to arrive in a couple of weeks. In the meantime I will create a customized firmware from QMK.

5 Likes

For the custom QMK firmware I cloned the official git repository and created a new layout using the following shell script. I believe the script used to be called new_project.sh and took arguments. Now all you do is run it and fill in the prompts.

git clone https://github.com/qmk/qmk_firmware.git

./util/new_keyboard.sh

Keyboard Name: test_keyboard
Keyboard Type [avr]: avr
Your Name: name

After the new keyboard was generated I navigated to keyboards/test_keyboard. Inside the config.h file I modified the following fields to map the firmware to my MCU pin configuration.

/* key matrix size */
#define MATRIX_ROWS 6
#define MATRIX_COLS 13

#define MATRIX_ROW_PINS { F0, F1, F4, F5, F6, F7 }
#define MATRIX_COL_PINS { B0, B1, B2, B3, B7, D0, D1, D2, D3, D4, B4, B5, B6 }

/* COL2ROW, ROW2COL */
#define DIODE_DIRECTION COL2ROW

It’s important that I use the correct COL and ROW direction since the traces will be passing through diodes. Inside of rules.mk I verified that the correct MCU and BOOTLOADER were set and enabled NKRO_ENABLED.

# MCU name
MCU = atmega32u4

# Bootloader selection
BOOTLOADER = atmel-dfu

# Build Options
# change yes to no to disable
#
BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration
MOUSEKEY_ENABLE = yes # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = no # Console for debug
COMMAND_ENABLE = no # Commands for debug and configuration
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
# if this doesn’t work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
NKRO_ENABLE = yes # USB Nkey Rollover
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
BLUETOOTH_ENABLE = no # Enable Bluetooth
AUDIO_ENABLE = no # Audio output

Inside of test_keyboard.h I defined the key matrix.

#define LAYOUT(
k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k10, k11, k12
k13, k14, k15, k16, k17, k18, k19, k20, k21, k22, k23, k24, k25
k26, k27, k28, k29, k30, k31, k32, k33, k34, k35, k36, k37, k38
k39, k40, k41, k42, k43, k44, k45, k46, k47, k48, k49, k50, k51
k52, k53, k54, k55, k56, k57, k58, k59, k60, k61, k62, k63, k64
k65, k66, k67, k68, k69, k70, k71, k72, k73, k74, k75, k76, k77
) {
{ k00, k01, k02, k03, k04, k05, k06, k07, k08, k09, k10, k11, k12 },
{ k13, k14, k15, k16, k17, k18, k19, k20, k21, k22, k23, k24, k25 },
{ k26, k27, k28, k29, k30, k31, k32, k33, k34, k35, k36, k37, k38 },
{ k39, k40, k41, k42, k43, k44, k45, k46, k47, k48, k49, k50, k51 },
{ k52, k53, k54, k55, k56, k57, k58, k59, k60, k61, k62, k63, k64 },
{ k65, k66, k67, k68, k69, k70, k71, k72, k73, k74, k75, k76, k77 },
}

Last I assigned all the keycodes under keymaps/default/keymap.c

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Base */
[_BASE] = LAYOUT(
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC,
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_BSPC,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_UP, KC_ENT,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN), KC_MENU, KC_RCTL, KC_BSLS, KC_DEL, KC_LEFT, KC_DOWN, KC_RIGHT
),
[_FN] = LAYOUT(
KC_PWR, KC_AUDIO_MUTE, KC_MEDIA_PLAY_PAUSE, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_BRIGHTNESS_UP,
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_BRIGHTNESS_DOWN,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_PSCREEN, KC_SCROLLOCK, KC_PAUSE,
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_INSERT, KC_HOME, KC_PGUP,
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_RSFT, KC_END, KC_AUDIO_VOL_UP, KC_PGDOWN,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_TRANSPARENT, KC_MENU, KC_RCTL, KC_BSLS, KC_DEL, KC_MEDIA_PREV_TRACK, KC_AUDIO_VOL_DOWN, KC_MEDIA_NEXT_TRACK
)
};

The placement of everything is subject to change though I think it’s fine for now. So far the only parts I received in the mail are these omron switches. I knew they were 6mm though they look much smaller in person.

4 Likes

The rest of the parts have arrived! The PCBs turned out pretty decent.

This was a large undertaking considering I haven’t soldered anything before. The end result looks good though.

All that’s left is to flash the firmware.

Looks good. I tested all the keys on both layers and everything is working.

4 Likes

That looks pretty cool! Now you just need a case and keys for it.

Bluetooth would make that a pretty cool htpc keyboard…

Thanks. I think in a later revision I may add Bluetooth as well. Initially I went with USB since I could not find any USB keyboards this size sold anywhere. I definitely want to make a case of some sort. Not sure if I can do the keys without a 3D printer though.

Anodized aluminum would be sweet for the housing, but costly unless you have access to milling machines. With 78 keys you might be able to find a prototype injection mold place that wouldn’t be horrible for lower volume making the keys. Still might be cheaper to buy a 3d printer though :laughing:

You can probably find some places that do 3d print as a service too. You just need to design the keys and housing, provide them with a .stl (or maybe a .step) and then iterate a few times.

doesn’t @Kiaxa like keyboards

That’s pretty groovy, could almost have it as a flip cover for a phone…

Duuuuuude this is sweet!

I added a plexiglass backplate with standoffs. This should protect the pins on the back from shorting and make it easier to hold. Also moved the LED to the backside since it was a poor design choice to have it pointing strait at the user.

Made some changes to the firmware as well. It will now toggle between 3 layers with the FN key. The third layer takes mouse input.

5 Likes

That looks great. Any plans for some form of keys to go on top?

Possibly. I’ve been playing with some ideas. Not sure how I would implement keys for these 6mm switches. I have the layout printed on the PCB but the font is a bit small to be practical. Keys would definitely improve the experience.

1 Like

This topic was automatically closed 273 days after the last reply. New replies are no longer allowed.