Story

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

Parts used

Tools used

  • Elegoo Saturn 4 Ulta
  • 3D Printer
  • Nose Plier

Step 1: Step 1:design & Customizing Button in Fusion360

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: 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

Step 3: 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 pageto 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 definitionsconstint buttonPin0 = D0; // Button for 'Ctrl + B'constint buttonPin1 = D1; // Button for Backspaceconstint buttonPin2 = D2; // Button for letter 'A'// Button statesbool lastState0 = HIGH;bool lastState1 = HIGH;bool lastState2 = HIGH;voidsetup(){// Initialize button pinspinMode(buttonPin0, INPUT_PULLUP);pinMode(buttonPin1, INPUT_PULLUP);pinMode(buttonPin2, INPUT_PULLUP);// Start Keyboard HID  Keyboard.begin();}voidloop(){// Read button statesbool 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 Backspaceif (currentState1 == LOW && lastState1 == HIGH) {    Keyboard.write(KEY_BACKSPACE); // Send Backspacedelay(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;}

Step 4: Wiring Diagram

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

Step 5: 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

Step 6: Testing

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

Read more »