- C++ 100%
| photos | ||
| stl | ||
| README.md | ||
| shifter.ino | ||
shifter
This is code for a racing simulation shifter using a physical button for each gear.
I have a Moza Racing HGP Shifter. It was great at first, but after a year it stopped consistently recognizing 2nd, 4th, and 6th. Recalibrating did not help. I still was happy with the feel of the shifter, so I bought eight snap switches, designed and 3D printed an assmebly to fit inside the shifter housing and hold the switches, wired them to an Arduino Nano ESP32 that I had, and wrote this code.
This shows up as a Bluetooth gamepad device called "shifter", and Assetto Corsa recognizes it. I have not tried it with any other games.
parts list
- Moza Racing HGP shifter
- (8) Omron SS-5GL2 snap switches
- Arduino Nano ESP32
- (18) M3x8 socket cap screws
- (18) M3 heat set inserts
- wire and filament
hardware
I designed the model in Onshape. It is published here on onshape.com
The printable model is published here on printables.com. The STL files are also here in ./stl/.
wiring
The wiring is simple: the bottom pin on each switch to the VBUS pin, and the middle pin each to a separate data pin. It does not matter which one, you can map them in software.
assembly
- Disassemble the shifter enough to remove the electronics.
- Cut a slot in the shifter housing where the USB port will be:
-
- 3D Print parts:
- (1) insert
- When slicing, the part needs to be cut into three pieces to print. The bottom needs to be cut separately so it can fit between the shifter base and assembly. Make it between 10mm and 12mm tall. The upper part needs to be cut in half vertically to make putting the threaded inserts and screws easier. Cut it at "V" in the side window.
- (1) cap
- (6) bracket_wide
- Black and purple in the photos; there is no difference other than color between the black ones and the purple ones.
- (2) bracket_narrow
- Yellow in the photos.
-
- (1) insert
- Place the base of the insert on the shifter base. Make sure orientation is correct:
-
- Attach the shifter mechanism to the base, 4 screws on the bottom.
-
- Solder wires from the switches to the Arduino.
- See later photos for an idea for length.
- Put the switches into the switch brackets.
-
- Insert the threaded inserts.
-
- Place the Arudino on the pins, and screw the cap on.
-
- Screw the switch brakets into the insert top pieces.
-
- Tape the insert top pieces together and place on the base.
-
- Slide the shifter housing over the inserts.
-
- Push the shifter housing all the way down and screw it to the shifter base, 4 screws on the bottom.
-
- Screw the top plate on, 4 screws on the top.
-
- Screw the shifter knob on.
-
- Plug it in and continue to software
software
building and installing
If you are more familiar with Arduino stuff, or use the Arduino IDE or some other IDE, you may have a better way to do this.
If you do not use Linux, sorry I cannot help you. (I am not saying you cannot be helped, I just do not have anything running Windows or MacOS and I have not developed on either of them in a very long time, so I cannot help you.)
Setup
- Install
arduino-cli arduino-cli core install arduino:esp32arduino-cli lib install NimBLE-Arduinoarduino-cli lib install ESP32-BLE-Gamepad
Compile
arduino-cli compile --fqbn esp32:esp32:nano_nora shifter.ino
Install
arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:nano_nora shifter.ino