Side project from March 2018 — an experiment in driving a real kart while wearing a VR headset.
A VR kart racing game that bridges a virtual Unreal Engine 4 world with a real Razor Crazy Cart XL. An Arduino Uno reads the physical accelerator pedal and drives the engine throttle through a DAC, while UE4 manages the game logic — track positioning, checkpoints, pickups, barriers — and can override throttle intensity in real time over serial.
- Razor Crazy Cart XL — the physical kart
- Arduino Uno — reads the accelerator pedal (analog input) and outputs throttle voltage via an Adafruit MCP4725 12-bit DAC
- VR headset & motion controllers — HTC Vive (or compatible SteamVR headset) for the in-game experience and controller calibration
kart/
├── arduino/ Arduino firmware
│ ├── src/main/ Main firmware (pedal → DAC → engine)
│ ├── src/test_dac/ Standalone DAC test sketch
│ └── libraries/
│ ├── kart/ Shared protocol defines (also included by UE4)
│ └── Adafruit_MCP4725/ Vendored DAC library
├── ue4/ Unreal Engine 4.19 project
│ ├── Source/kart/ C++ game module
│ └── Content/ Blueprints, levels, meshes, materials, sounds
├── assets/ Source art (Blender), sounds (MP3), textures (JPG)
└── deploy.bat Copies release build to network share
- The Arduino reads pedal voltage, normalizes it to a 0–1 intensity, and outputs a corresponding throttle voltage (1.5–3.2 V) through the MCP4725 DAC.
- UE4 connects to the Arduino over serial (9600 baud, auto-detected COM port) using a background thread for non-blocking communication.
- The game can read current pedal/throttle intensity and set constraints — max intensity caps and periodic throttle cuts — to tie real-world kart behavior to in-game events (e.g. slow down on collision, cut throttle when out of track).
- A VR track system maps the physical driving space to virtual track geometry, tracking checkpoints, lap progress, and out-of-bounds detection.
- Windows (serial communication uses Win32 API)
- Unreal Engine 4.19
- Arduino IDE with the
Adafruit_MCP4725library (vendored inarduino/libraries/) - SteamVR-compatible headset and controllers
Open ue4/kart.uproject in Unreal Engine 4.19 and build from the editor or via Unreal Build Tool.
- Open
arduino/src/main/main.inoin the Arduino IDE. - Make sure the Arduino IDE library path includes
arduino/libraries/(forkart/shared_defines.handAdafruit_MCP4725). - Upload to the Arduino Uno.
Run deploy.bat to mirror the packaged release build to the network share.
The Arduino and UE4 share command definitions via arduino/libraries/kart/shared_defines.h. Communication is binary at 9600 baud.
| ID | Command | Direction | Payload |
|---|---|---|---|
| 1 | CMD_GET_ACCELERATOR_INTENSITY |
UE4 → Arduino → UE4 | Returns float |
| 2 | CMD_SET_ACCELERATOR_MAX_INTENSITY |
UE4 → Arduino | Sends float |
| 3 | CMD_SET_ACCELERATOR_CUT_DELAY |
UE4 → Arduino | Sends int |
| 4 | CMD_GET_THROTTLE_INTENSITY |
UE4 → Arduino → UE4 | Returns float |
On startup the Arduino sends its ID byte (77). UE4 scans COM ports for an "Arduino Uno" device and validates this ID to establish the connection.