JaimyvS
Created November 5, 2022 © CC BY-NC

Gaming Pirate Wheel

A 3D printed pirate ship wheel to play your favorite pirate games in style.

BeginnerWork in progress2 hours650
Gaming Pirate Wheel

Things used in this project

Hardware components

Raspberry Pi Pico
Raspberry Pi Pico
×1
Rotary Encoder with Push-Button
Rotary Encoder with Push-Button
Any rotary encoder with the same dimensions works.
×1

Software apps and online services

Mu Editor
Any supported code editor

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Code

Python code

Python
This is the code for the Raspberry Pi Pico.
#### Created by Jaimy van Schelven - 2022 ####
#### Uses Adafruit Circuitpython 7 ####

import time
import rotaryio
import board
import usb_hid
from adafruit_hid.mouse import Mouse
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.keycode import Keycode

last_position = None
last_time = None
current_time = None
diff = 1

encoder = rotaryio.IncrementalEncoder(board.GP12, board.GP13) # Change these if you connected the encoder to different pins.
keyboard = Keyboard(usb_hid.devices)
keyboard_layout = KeyboardLayoutUS(keyboard)

while True:
    current_time = time.monotonic()
    position = encoder.position
    if last_position != None:
        if last_position < position: #Wheel rotates left
            keyboard.press(Keycode.A) #Change this if your game expects another key for turning left.
            time.sleep(0.1)
            last_time = current_time
        elif last_position > position: #Wheel rotates right
            keyboard.press(Keycode.D) #Change this if your game expects another key for turning right.
            time.sleep(0.1)
            last_time = current_time
        elif last_position == position: #Wheel is still
            if last_time != None:
                if current_time - last_time < diff:
                    keyboard.release_all()
    last_position = position

Credits

JaimyvS
1 project • 0 followers

Comments