Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Elecrow
Published

Teach You How to Create Your Own Mechanical Keyboard

Build your own custom multi-mode mechanical keyboard for just $30.

IntermediateFull instructions provided2 days106
Teach You How to Create Your Own Mechanical Keyboard

Things used in this project

Hardware components

Raspberry Pi Pico
×1
Elecrow Crowpi L
×1
Elecrow $1 PCB Prototype
Elecrow $1 PCB Prototype
×1
Elecrow 3D Printing Service
Elecrow 3D Printing Service
×1
Elecrow Online Acrylic Cutting
Elecrow Online Acrylic Cutting
×1
Elecrow Online PCB Assembly
Elecrow Online PCB Assembly
×1

Story

Read more

Custom parts and enclosures

keyboard shell

Code

keyboard code

Python
from analogio import AnalogIn
from digitalio import DigitalInOut,Direction,Pull
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
import board
import usb_hid
import time

keyboard = Keyboard(usb_hid.devices)
button_pin = [0, board.GP5,  board.GP4,  board.GP3,  board.GP2,  board.GP1,
                 board.GP10,  board.GP9,  board.GP8,  board.GP7,  board.GP6,
                 board.GP15, board.GP14, board.GP13, board.GP12, board.GP11,
                 board.GP16, board.GP17, board.GP18, board.GP19]
button_num = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]

for i in range(1,len(button_num)):
    button_num[i] = DigitalInOut(button_pin[i])
    button_num[i].direction = Direction.INPUT
    button_num[i].pull = Pull.DOWN

if __name__ == "__main__":
    while True:
        adc = AnalogIn(board.A0)
        val = adc.value
        print(val)
        if val < 10500:
            button_value = [0, Keycode.TAB, Keycode.ONE, Keycode.TWO, Keycode.THREE, Keycode.FOUR,
                            Keycode.ALT, Keycode.Q, Keycode.W, Keycode.E, Keycode.R, Keycode.SHIFT,
                            Keycode.A, Keycode.S, Keycode.D, Keycode.F, Keycode.CONTROL,
                            Keycode.C, Keycode.V, Keycode.SPACE]
            for j in range(1,len(button_num)):
                if button_num[j].value:
                    keyboard.press(button_value[j])
                    time.sleep(0.1)
                    keyboard.release(button_value[j])
        elif val > 10500 and val < 33000:
            button_value = [0, Keycode.ONE, Keycode.TWO, Keycode.THREE, Keycode.FOUR, Keycode.FIVE,
                            Keycode.SIX, Keycode.SEVEN, Keycode.EIGHT, Keycode.NINE, Keycode.ZERO, Keycode.SHIFT,
                            Keycode.A, Keycode.S, Keycode.D, Keycode.F, Keycode.CONTROL,
                            Keycode.C, Keycode.V, Keycode.SPACE]
            for j in range(1,len(button_num)):
                if button_num[j].value:
                    keyboard.press(button_value[j])
                    time.sleep(0.1)
                    keyboard.release(button_value[j])
        time.sleep(0.1)
        adc.deinit()

Credits

Elecrow
16 projects • 9 followers
We are an open-source hardware provider and PCB manufacturer. As low as $1/10pcs. Elecrow Partner Seller Program is in full swing!
Contact

Comments

Please log in or sign up to comment.