Black technology: how programmers create their own split keyboard

foreword

I always wanted to buy a mechanical keyboard before, but I heard that the mechanical keyboard is very cool to type codes and play games, and it is also a B artifact. At the same time, I also feel that the wrist will be a bit sore after typing on the ordinary keyboard for a long time, because the wrist is bent when typing on the keyboard, which is not ergonomic at all. So I wanted to buy a split mechanical keyboard, but I couldn't find anything I liked for a long time. I found a few ergonomic keyboards, all of which are made of thin film, and the price is ridiculously high, so there are many ergonomic halos. . . .

Ordinary mechanical keyboard

taobao ergonomic keyboard

taobao split keyboard

In order not to be so entangled, I just DIY one myself. I happen to have a 3D printer, all the casings are printed by myself, the control board uses Arduino Leonardo, natively supports keyboard and mouse drivers, and the shaft body is Taobao. Considering the cost, I first bought 80 domestic black shafts to make Experiment, simply print the keycaps, just do what you say

final result

Prepare

  • tool
    • 3D printer
    • soldering iron
    • hot melt adhesive
    • multimeter
  • hardware
    • Arduino Leonardo board
    • black shaft
    • Diode + Resistor + Dupont Line + Universal Board
    • small screw
  • software
    • SolidWorks 3D Modeling
    • Arduino IDE to write Arduino keyboard driver

It's time for some pictures. . .

Self-assembled delta 3D printer

Tools from Taobao



step

First design the key layout, use SolidWorks to draw a simple key layout, start with the left hand, first complete the left hand, and then make the right hand. After designing the layout, make the panel supporting the shaft body, then design the circuit, solder with flying leads, and write code to test whether the keys are normal. After the circuit is normal, the entire housing is designed and then assembled as a whole. it's done

  • key design

    • left hand
      left hand
    • Right hand (the shape is distorted because of the limited printing area of ​​the 3D printer)
      right hand
  • circuit design

    Due to the limited io ports of the Arduino board, scanning must be used to implement keys. Arduino has 6 analog ports and 14 digital ports. The keyboard I want to make does not have more than 80 keys, so I use 8 digital ports for pulse scanning, 6 analog ports and 4 digital ports to receive pulses to locate the keys, thus realizing an 8*10 matrix, supporting 80 key. There are also 2 numeric keys that are free and can be used for special key customization.

    • Conflict handling
      Using the pulse scanning method, there will be a button conflict problem. I use a diode to handle the conflict, as shown in the figure (R is the scan port, C is the receiving port):
       
    • The voltage turbulence processing
      diode solves the conflict problem, but it cannot solve the voltage turbulence. There are two aspects of voltage instability. The first is that when the high voltage of the scanning port changes to a low voltage, the voltage of the receiving port will not immediately become a low voltage, so when receiving All ports need to add a pull-down resistor to drop the voltage immediately. The second is the voltage instability caused by the collision of the contact pieces when the button is pressed. This is best to filter the fluctuating voltage by adding capacitors. When buying components, I forgot to buy capacitors. Here it is simple and rude

    • final circuit design

  • Shell Design

    • left hand
    • right hand
    • side
  • keycap design


  • programming

#include "Keyboard.h"#include "HID.h"#define scanPin_len 8int scanPin[] = {4,5,6,7,0,1,2,3}; // 扫描pin,(默认高电平,逐个输出低电平)int scanPos = 0; // 当前扫描位#define btnPinA_len 6#define btnPinD_len 4int btnPinA[] = {5,4,3,2,1,0}; // 按钮pin,模拟端口int btnPinD[] = {8,9,10,11}; // 按钮pin,数字端口#define btn_len 10byte btn[scanPin_len][btn_len]; // 按钮状态byte btnTmp[btn_len]; // 临时按钮状态#define KEY_FN KEY_RIGHT_SHIFT // FN键uint8_t keyMap[scanPin_len][btn_len] = 
{
{'y','n','7','8',KEY_F6,'h','m','u','j',' '},
{'o','.','0','9',KEY_F7,'l',',','i','k',KEY_FN},
{'p','/','-',KEY_LEFT_ARROW,KEY_F8,';',KEY_UP_ARROW,'[','\'',KEY_DOWN_ARROW},
{KEY_F10,KEY_DELETE,'=',KEY_BACKSPACE,KEY_F9,KEY_F11,KEY_RETURN,']','\\',KEY_RIGHT_ARROW},
{KEY_ESC,KEY_LEFT_GUI,'`',KEY_LEFT_CTRL,KEY_TAB,'a','q','z',KEY_CAPS_LOCK,KEY_LEFT_SHIFT},
{KEY_F1,KEY_LEFT_ALT,'1',KEY_F2,'2','s','w','x','d','c'},
{KEY_F3,' ','4',KEY_F4,'3','e','r','b','f','v'},
{KEY_F5,'6','5',0,0,0,'t','g',0,0}
}; 

void setup() {
  Keyboard.begin();
  Keyboard.releaseAll();
  Serial.begin(9600);  // 初始化扫描pin
  for(int i=0; i<scanPin_len; i++) {
    pinMode(scanPin[i], OUTPUT);
  }  // 初始化按钮pin
  for(int i=0; i<btnPinD_len; i++) {
    pinMode(btnPinD[i], INPUT);
  }  // 初始化按钮状态
  for(int i=0; i<scanPin_len; i++) {    for(int j=0; j<btn_len; j++) {
      btn[i][j] = 0;
    }
  }  for(int j=0; j<btn_len; j++) {
    btnTmp[j] = 0;
  }
}void loop() {  // 轮询设置scanPin
  for(int i=0; i<scanPin_len; i++) {    if(i == scanPos) {
      digitalWrite(scanPin[i], HIGH);
    } else {
      digitalWrite(scanPin[i], LOW);
    }
  }

  delay(5);  // 读取按键信息
  readBtn();  // 处理状态有改变的btn

  for(int i=0; i<btn_len; i++) {    if(btn[scanPos][i] != btnTmp[i]) {
      btn[scanPos][i] = btnTmp[i];//      Serial.print("["); //      Serial.print(scanPos);//      Serial.print(" : ");//      Serial.print(i);

      if(btnTmp[i] == 1) {
        Keyboard.press(keyMap[scanPos][i]);//        Serial.print("] pressed");
      } else {
        Keyboard.release(keyMap[scanPos][i]);//        Serial.print("] released");
      }//      Serial.println("");
    }
  }
 scanPos = (scanPos + 1) % scanPin_len; // 下一个}void readBtn() {  // 先读模拟口,再读数字口
  // 5 -> 0
  int index = 0;  for(int i = 0; i < btnPinA_len; i ++) {    int val = analogRead(btnPinA[i]);    if(val > 600) {
      btnTmp[index] = 1;
    } else {
      btnTmp[index] = 0;
    }    // Serial.print(btnTmp[index]);
    index ++;
  }  for(int i = 0; i < btnPinD_len; i ++) {
    btnTmp[index] = digitalRead(btnPinD[i]);    // Serial.print(btnTmp[index]);
    index ++;
  }
}

Make an atlas

  • First Edition Keycaps:

  • The newly purchased frosted glass was heated unevenly and shattered during printing. . .

  • During printing, the heating head was loose and dropped. Fortunately, the machine has automatic protection and did not cause a fire.

  • The base fell off during the printing process, and the journey was bumpy.

  • Shaft installation

  • flying line

  • ArduinoLeonardo has not arrived yet, take the uno to test the button

  • Shell assembly effect

  • The first version of the keycaps (the letters are pasted with textured paper)

  • Leonardo arrives, test drive

  • The right hand is assembled successfully (black is more feeling)

  • New keycaps (white)

  • circuit board

  • final effect

Summarize

It feels very fulfilling and practical to complete the whole keyboard. It has been used for nearly half a year so far, and I am very used to the key feedback of the mechanical keyboard, and my wrists are no longer bent, and there is no acid. Finally, let's sum up the cost

  • 80 domestic black shafts 104 yuan
  • Components 24 yuan (postage is expensive, and there are many diodes and universal boards that are not used)
  • Leonardo 30 yuan
    probably costs about 160 yuan for materials, which is much cheaper than ordinary mechanical keyboards, and it is also split, and all keys can be customized at will (the driver is written by itself, O(∩_∩)O haha~)

Finally, take a look at my desk in the dark room

If you feel that the content is still unfinished, if you want to know more relevant information, please scan the following QR code, follow our public account , you can get more technical dry goods, and share exciting activities with you~

Tencent Bugly is a quality monitoring tool specially built for mobile developers , helping developers quickly and easily locate online application crashes and solutions. The intelligent merge function helps developers to merge and classify thousands of crashes reported every day  according  to the root cause. The daily report will list the crashes that affect the most users. The precise location function helps developers to locate the problematic line of code. Real-time reporting can Quickly understand the quality of the application after the release, adapt to the latest iOS, Android official operating system, the engineers of the goose factory are using it, come and join us!


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324426847&siteId=291194637