Cameron Coward
Published © CC BY-NC-SA

The Expletive Keyboard

I built a keyboard that contains only the letters you really need.

IntermediateFull instructions provided2 hours8,218
The Expletive Keyboard

Things used in this project

Hardware components

Raspberry Pi Pico
Raspberry Pi Pico
×1
Cherry MX Key Switches
×1
Key Stabilizers
×1
Key Caps
×1

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Custom parts and enclosures

Top

Bottom

Top Fusion 360 File

Bottom Fusion 360 File

Code

code.py

Python
Copy onto Raspberry Pi Pico "circuitpy" folder
import time
import digitalio
import board
import usb_hid
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keycode import Keycode
from adafruit_hid.mouse import Mouse

btn1_pin=board.GP2
btn2_pin=board.GP3
btn3_pin=board.GP4
btn4_pin=board.GP6
btn5_pin=board.GP7
btn6_pin=board.GP8
btn7_pin=board.GP10
btn8_pin=board.GP11
btn9_pin=board.GP12
btn10_pin=board.GP13

keyboard = Keyboard(usb_hid.devices)
mouse = Mouse(usb_hid.devices)

btn1 = digitalio.DigitalInOut(btn1_pin)
btn2 = digitalio.DigitalInOut(btn2_pin)
btn3 = digitalio.DigitalInOut(btn3_pin)
btn4 = digitalio.DigitalInOut(btn4_pin)
btn5 = digitalio.DigitalInOut(btn5_pin)
btn6 = digitalio.DigitalInOut(btn6_pin)
btn7 = digitalio.DigitalInOut(btn7_pin)
btn8 = digitalio.DigitalInOut(btn8_pin)
btn9 = digitalio.DigitalInOut(btn9_pin)
btn10 = digitalio.DigitalInOut(btn10_pin)

btn1.direction = digitalio.Direction.INPUT
btn2.direction = digitalio.Direction.INPUT
btn3.direction = digitalio.Direction.INPUT
btn4.direction = digitalio.Direction.INPUT
btn5.direction = digitalio.Direction.INPUT
btn6.direction = digitalio.Direction.INPUT
btn7.direction = digitalio.Direction.INPUT
btn8.direction = digitalio.Direction.INPUT
btn9.direction = digitalio.Direction.INPUT
btn10.direction = digitalio.Direction.INPUT

btn1.pull = digitalio.Pull.DOWN
btn2.pull = digitalio.Pull.DOWN
btn3.pull = digitalio.Pull.DOWN
btn4.pull = digitalio.Pull.DOWN
btn5.pull = digitalio.Pull.DOWN
btn6.pull = digitalio.Pull.DOWN
btn7.pull = digitalio.Pull.DOWN
btn8.pull = digitalio.Pull.DOWN
btn9.pull = digitalio.Pull.DOWN
btn10.pull = digitalio.Pull.DOWN

while True:

    if btn1.value:
        print("Button 1 pressed")
        keyboard.press(Keycode.LEFT_SHIFT,Keycode.F)
        time.sleep(0.05)
        keyboard.release(Keycode.LEFT_SHIFT,Keycode.F)

    if btn2.value:
        print("Button 2 pressed")
        keyboard.press(Keycode.LEFT_SHIFT,Keycode.U)
        time.sleep(0.05)
        keyboard.release(Keycode.LEFT_SHIFT,Keycode.U)

    if btn3.value:
        print("Button 3 pressed")
        keyboard.press(Keycode.LEFT_SHIFT,Keycode.C)
        time.sleep(0.05)
        keyboard.release(Keycode.LEFT_SHIFT,Keycode.C)

    if btn4.value:
        print("Button 4 pressed")
        keyboard.press(Keycode.LEFT_SHIFT,Keycode.K)
        time.sleep(0.05)
        keyboard.release(Keycode.LEFT_SHIFT,Keycode.K)

    if btn5.value:
        print("Button 5 pressed")
        keyboard.press(Keycode.BACKSPACE)
        time.sleep(0.05)
        keyboard.release(Keycode.BACKSPACE)

    if btn6.value:
        print("Button 6 pressed")
        keyboard.press(Keycode.ENTER)
        time.sleep(0.05)
        keyboard.release(Keycode.ENTER)

    if btn7.value:
        print("Button 7 pressed")
        keyboard.press(Keycode.LEFT_SHIFT,Keycode.U)
        time.sleep(0.05)
        keyboard.release(Keycode.LEFT_SHIFT,Keycode.U)

    if btn8.value:
        print("Button 8 pressed")
        keyboard.press(Keycode.LEFT_SHIFT,Keycode.O)
        time.sleep(0.05)
        keyboard.release(Keycode.LEFT_SHIFT,Keycode.O)

    if btn9.value:
        print("Button 9 pressed")
        keyboard.press(Keycode.LEFT_SHIFT,Keycode.Y)
        time.sleep(0.05)
        keyboard.release(Keycode.LEFT_SHIFT,Keycode.Y)

    if btn10.value:
        print("Button 10 pressed")
        keyboard.press(Keycode.SPACE)
        time.sleep(0.05)
        keyboard.release(Keycode.SPACE)

    time.sleep(0.1)

Credits

Cameron Coward

Cameron Coward

10 projects • 832 followers

Comments