Raspberry Pi Pico Racing Wheel

Introduction: Raspberry Pi Pico Racing Wheel

Raspberry Pi Pico is interesting board for making interesting projects from programming. I use Pico board as mouse in Euro Truck Simulator 2. Using potentiometer I measure analog values and convert to movement of mouse in my computer.

Step 1: BOM

You will need:

1. Raspberry Pi Pico

2. potentiometer 1 kOHM

3. breadboard & dupont cables

4. 100 ohm resistor for 100 % sure for protecting analog pin

For sure, you can check potentiometer pins, if resistance betweem 1 and 3 pins is 1 kohm always.

Step 2: Wiring

Wiring is simple:

1. GND (3 pin on Pico)

2. analog pin on 10 pin Pico

3. VCC = 3,3 V on 5 pin Pico

For sure, you can add in serial to analog pin 100 ohm resistor.

Step 3: Software and Code

You will need to install:

1. Circuit Python from Adafruit

https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython

2. adafruit_hid folder from:
https://learn.adafruit.com/circuitpython-essentials/circuitpython-hid-keyboard-and-mouse

3. MU Editor (optional):

https://learn.adafruit.com/getting-started-with-raspberry-pi-pico-circuitpython/installing-mu-editor

https://codewith.mu/

Code is simple, you will need only create code.py and copy this code (code.py file is created as default).

Be care of wrong blanks. Python language use blank with proper size (use TAB if errors in code)!

import time
import usb_hid
from adafruit_hid.mouse import Mouse
import board
import analogio
mouse = Mouse(usb_hid.devices)
time.sleep(1)
potentiometer = analogio.AnalogIn(board.GP26)
y=0
while True:
    x=int(potentiometer.value/200)
    if abs(y-x)>2:
        print("posun "+str(y-x))
        mouse.move(-(y-x))
    print(x)
    y=int(potentiometer.value/200)
    time.sleep(0.2)


Be the First to Share

    Recommendations

    • Retro Tech Challenge

      Retro Tech Challenge
    • Organization Contest

      Organization Contest
    • Lamps and Lighting Contest

      Lamps and Lighting Contest

    Comments