RGB One Button USB Keyboard

4,425

48

15

About: Amateur electronics and 3D printing enthusiast.

Ever felt the need to have a tiny, yet functional, RGB backlit keyboard, no bigger than the size of a single key? No? Who cares, make one anyway! This instructable will guide you through the steps you need to make your very own, slightly useless, one button keyboard.

Step 1: Parts and Tools

To make this project, you will need...

Parts:

  • An ATtiny85 based development board. These boards are clones of the Digispark board, and can be bought for as little as 1-2GBP/USD. There are a few versions of this board, one which has a built in USB A connector, and two that have a built in Micro USB socket. The one needed for this project is the smaller of the two that has "TINY85" written on it as apposed to "ATTINY85". All boards will function the same, but only this one will fit in the 3D printed case.
  • A WS2812b RGB LED. These also come in different forms, the type needed are mounted on a tiny round PCB, little bigger than the LED itself. A bare LED can also be used, but bear in mind these will be very difficult to solder to.
  • A Cherry MX/ Cherry MX Compatible switch. Switches with clear housings are ideal as they will allow the LEDS light to pass through.
  • A Cherry MX compatible keycap.

Tools:

  • A Soldering Iron and Solder will be needed. Flux, Solder Braid/Wick, a set of Third Hands, and more Flux are helpful too.
  • A 3D printer is required to print the enclosure, but something similar can also be fasioned out of wood, acrylic, MDF, etc if you have access to basic hand tools. A case can also be cut out of a small ABS project box.

Step 2: Setting Up the Software

First, you will need to install the Arduino IDE and Digispark drivers. To do this, follow the instructions here. Upload the blink sketch included in the linked page, to make sure your board works. Next, you will need to install the Adafruit Neopixel Library, to control the led. In the Arduino IDE, go to Tools > Manage Libraries and search for "Adafruit Neopixel." Download and install the library of the same name.

Step 3: Printing the Case

The STL files needed for the case and the example code can be downloaded from thingiverse here. Download and print the both parts of the case now, and make sure you hang on to the code - you'll need that later.

Step 4: Wiring and Assembly

Wire up the components as shown in the diagram and images. The leds data pin should be connected to pin P1 on the board, and the switch should be connected to P2. Make sure you connect P1 to the leds data IN pin, and not the data OUT pin. Next, carefully insert the board into the case. Its a tight fit, and once its in, it will be very difficult to remove, so double check your wiring before hand. Then, line up the micro usb port with the corresponding cutout on the case, wedge a flathead screwdriver (or similar tool) behind the board and use it to push the socket into the cutout. It should fit in tightly. Use hotglue to hold the board in place. Finally, align the two indents in the top of the enclosure with the two protrusions in the base, and fit them together. Bear in mind that the case is NOT designed to be reopened after assembly, if unsure about your wiring, flash the code (as shown in the next step) and test the led and switch before fitting into the case.

Step 5: Flashing and Modifying the Code.

Unzip the example code you downloaded from Step 3, and open it in the Arduino IDE. This simple sketch allows you to set the backlight to your desired colour, and map a key to the switch. Modify the variables backlightR,G and B to pick the colour you would like the backlight to be, and backlightBrightness to modify the intensity of the led. All four of these variables must have a number from 0 (off) to 255 (maximum). To map a key, modify the variable "keyCode" to with whichever key you like. A list of keycodes can be found here. Once you have modified the code to your liking hit the upload button, to compile and flash the code to your board. Once its done compiling, the terminal will prompt you to plug in your board. Make sure you plug it in within 60 seconds, or you will have to repeat the upload process.

Step 6: Done!

You should now have a fully functional single key keyboard! The provided code mimics a regular USB HID keyboard, so it can be used without any installing additional software, though you can download macro programs such as AutoHotkey to automate actions when you press the key. If you want to customize the code more than what is offered by the example code, you can write your own using the Digikeyboard library. The FastLED library can also be used to control the led and offers much more powerful functions than Adafruit_Neopixel.

If you liked this instructable, please consider voting for it in the Big and Small Contest, have fun making!

Big and Small Contest

Participated in the
Big and Small Contest

Share

    Recommendations

    • Sensors Contest

      Sensors Contest
    • Backyard Contest

      Backyard Contest
    • Planter Challenge

      Planter Challenge

    15 Discussions

    1
    None
    bloggerstomper

    Question 17 days ago

    Hi!
    This is a great tutorial!
    I just wanted to ask if it's possible to program more than one keycode in.
    For example, I would like to use the button to lock my screens away when I leave my Mac.
    Is this possible??

    Thank you!!!

    1 answer
    0
    None
    blaablaaguybloggerstomper

    Answer 13 days ago

    Yep, that should definitely be possible.

    Been a while since a made this, and I don't have the script in front of me, but as far as I can remember you should be able to just copy and paste the line that sends the keystroke (DigiKeyboard.sendKeyStroke), change the variable it contains to a new one (eg, keyTwo), and assign a new value to to that variable. You can repeat this process to add as many keypresses as you like, until you run out of space on the microcontroller. Its a very simple bit of code, shouldn't be too hard to modify. Hope this helps.

    1
    None
    Incendium87

    2 months ago

    This is great! I can finally end the mild annoyance of not having a windows key on an old IBM model M.

    Two questions:
    -Can you post links to the specific components you used? I am having trouble finding parts that match your description. Especially the LED.
    -Could this be used to automate actions directly in the button code or have the code send a key combination instead of a single key, without using AutoHotKey? It would be nice to have the single button do something specific without also mapping a standard key from a keyboard. Or would you just tie the button and AutoHotKey script to something like an F15 key or something else thats not on standard keyboard?

    2 replies
    0
    None
    blaablaaguyIncendium87

    Reply 2 months ago

    Youll need a WS2812B Led. The ones I used were on a breakout board like this, but you could cut one off from a strip and solder to that.
    https://www.amazon.com/ALITOVE-100pcs-WS2812B-Addressable-Module/dp/B00P2GQUYC/ref=mp_s_a_1_8?keywords=ws2812b&qid=1557955549&s=gateway&sprefix=ws281&sr=8-8

    The board is a digispark clone, like this one. https://www.amazon.com/Frentaly®-Digispark-Kickstarter-Attiny85-Development/dp/B0179Z758I/ref=mp_s_a_1_15?keywords=attiny85&qid=1557955902&s=gateway&sprefix=attiny&sr=8-15

    Any CHERRY MX compatible switch and keycaps will work.

    As for the second question, yeah, thats certainly possible. I wrote that sketch a while ago, but it should be simple to modify it to send multiple keycodes. Look into the DigiKeyboard library for that, it should more or less be as simple as copying and pasting the function that sends the keystroke. The library also has a function to send a string of text as well.

    This might be of interest to you. The board is seen as a regular HID device, like any keyboard, so you can send whichever, and as many keys as you like. https://youtu.be/fGmGBa-4cYQ

    1
    None
    Incendium87blaablaaguy

    Reply 8 weeks ago

    Thanks for the links. The quick searching I did before posting my question only brought up the LEDs without the premounted PCB and the ATTINY85 board that you said would be bigger than desired. So thanks for the better sources.

    1
    None
    wade.van.horn

    5 months ago on Introduction

    Cool project. Two quick questions: 1) I can't find the example code, am I missing it? 2) Is there an easy way to have the switch activate a "mailto" for a particular email address?
    Thanks, in advance.

    1 answer
    0
    None
    blaablaaguywade.van.horn

    Answer 5 months ago

    The example code should be in the thingiverse link, along with the 3d printable files. It allows you to send any keypress, so you could probably map the key to an unused key (like f13) and use something like autohotkey to perform an action (like your mailto) when f13 is pressed. Not something ive tried though.

    1
    None
    iAakashD

    6 months ago

    Great project...

    2
    None
    HalalC

    6 months ago

    MashaAllah. Good

    2
    None
    Ajaz Ali KalamM

    6 months ago

    this is really interesting,smart engineering involves breaking out of traditional designs.

    3
    None
    Alex in NZ

    6 months ago

    Very silly. I love it :-) Thank you for sharing the idea.

    3
    None
    ZakerahA

    6 months ago

    Pure genius

    1
    None
    DeenA3

    6 months ago

    Nice one, teggy breath!

    2
    None
    FabioJohnShakeel

    6 months ago

    I see a bright future ahead of you, boy.

    ~(0_0)~