3D Printed Tiny Programmable Hotkey Keyboard

by gokux in Circuits > Gadgets

5487 Views, 120 Favorites, 0 Comments

3D Printed Tiny Programmable Hotkey Keyboard

6.jpg

I've created a small 3-button keyboard with a customisable button. It allows for easy programming to assign preferred hotkeys to each button. The best part is that no drivers or supporting software are needed for this device; it is plug-and-play, just like an ordinary keyboard. For example, I'm going to map it for my video editing software (DaVinci Resolve) to quickly switch between selection and cutting tools, as well as the delete button. We are using the Seeed Studio XIAO SAMD21 for this project, and it is also completely 3D printable. I will also demonstrate what is possible to do with resin printing. I used the Elegoo Saturn 4 Ultra for this project. Don't worry if you don't have a resin printer; it is also possible to print in FDM printers too.

Supplies

DSC01833.JPG

Parts used 

  1. 1*Seeed Studio XIAO SAMD21
  2. 3*OMRON 12x12x7.3mm Tactile 4 Pin Push Button Switch
  3. 1*80ohm resistor 
  4. 1*Red Rectangle flat LED 5*2mm
  5. USB C cable 
  6. B7000 Industrial Glue 

Tools used 

  1. Elegoo Saturn 4 Ulta 
  2. 3D Printer 
  3. Nose Plier

Step 1:design & Customizing Button in Fusion360

imeage1-19.jpg

I use Fusion360 for the design of this project. If you want a custom logo or icon on your button, all you need is the vector (.svg) file of the design. Import it as an SVG on top of the button and extrude it by 0.6mm.


Step 2: 3D Printing

I am using the Elegoo Saturn 4 Ultra for 3D printing in this project. The main body is printed using Elegoo Red standard resin, and the buttons are printed using Elegoo Black standard resin. After printing, I washed it with IPA and cured it in UV light, which are standard procedures in SLA printing

Code

We only need a few lines of code to accomplish this. We are using the keyboard.h library for this project. You can visit this page to learn how to assign buttons according to your specific requirements.

You can actually flash this code to XIAO before or after assembling it.

Note: If you input 'B' in the keyboard.press function, it means 'shift + B'. If you want to trigger only the button 'B', you should input 'b'.


#include <Keyboard.h>

// Pin definitions
const int buttonPin0 = D0; // Button for 'Ctrl + B'
const int buttonPin1 = D1; // Button for Backspace
const int buttonPin2 = D2; // Button for letter 'A'

// Button states
bool lastState0 = HIGH;
bool lastState1 = HIGH;
bool lastState2 = HIGH;

void setup() {
// Initialize button pins
pinMode(buttonPin0, INPUT_PULLUP);
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);

// Start Keyboard HID
Keyboard.begin();
}

void loop() {
// Read button states
bool currentState0 = digitalRead(buttonPin0);
bool currentState1 = digitalRead(buttonPin1);
bool currentState2 = digitalRead(buttonPin2);

// Check for button press on D0 for 'Ctrl + B'
if (currentState0 == LOW && lastState0 == HIGH) {
Keyboard.press(KEY_LEFT_CTRL); // Press Ctrl
Keyboard.press('b'); // Press 'B'
delay(10); // Short delay to register keys
Keyboard.releaseAll(); // Release both keys
}
lastState0 = currentState0;

// Check for button press on D1 for Backspace
if (currentState1 == LOW && lastState1 == HIGH) {
Keyboard.write(KEY_BACKSPACE); // Send Backspace
delay(10); // Short delay to register key
}
lastState1 = currentState1;

// Check for button press on D2 for letter 'A'
if (currentState2 == LOW && lastState2 == HIGH) {
Keyboard.write('A'); // Send letter 'A'
delay(10); // Short delay to register key
}
lastState2 = currentState2;
}

Wiring Diagram

WQD.jpg

The small LED is utilized to provide illumination for the 3D print. By adjusting the resistor value, you can control the brightness of the LED

Assembly

5.1

Put the key cap on top of the push button. and place that button on the main body 

5.2

Then I completed all the wiring according to the wiring diagram. I also glued the LED onto the 3d print 

5.3

Then I glued the back cap onto the 3d print 

5.4

Now you can make changes in the code as you like and upload it to XIAO

Testing

Now we can connect it with our USB C cable to our PC in order to test it