First, the Arduino thing is positioned to point at the back tires of a stationary bike. (I’m using a mountain bike on an indoor trainer but the beauty of this non-invasive approach is that you could use it with treadmills, ellipticals, rowing machines, or anything that has a looping/revolving surface.)

A strip of paper is taped to the tire. Each time the wheel makes a complete rotation, the Arduino will detect when the piece of paper passes by and then sends a wireless message to the mobile phone.

The mobile phone is placed in a viewer that is strapped to my face. (I used a $10 headset that more comfortably fits the iPhone 6S Plus, but any ol’ viewer will do.)

In software, a virtual bike is created to travel in a virtual environment. The virtual bike will only nudge forward whenever the app receives a message from the Arduino reporting that the physical bike’s wheel has made a complete rotation. We are effectively mapping the physical action of pedaling to movement in the virtual space to make an oversized gaming controller.

The virtual environment is constructed in Unity. To render for virtual reality, I’m using Google Cardboard – a free software SDK for mobile VR. The SDK for Unity is drop dead simple – just drag and drop a prefab into your scene and you’ll instantly have a stereo camera rig to manipulate.

This camera rig is set to move along a spline path whenever the app receives a BLE ping from the Arduino. That’s pretty much all it takes! So there you have it, a VR cycling experience for a whopping total of $40:

Arduino thing? $30.

Mobile VR headset? $10.

Software? Priceless.

Yes it’s DIY, but to put things in perspective, take a look at the current offerings on the market today:

Peloton: $2,000 bike with built in touchscreen monitor. No VR. Pedaling does not affect the video screensaver 😦

This was a fun little personal project and I’ve learned what I set out to learn, so this is where I move on – but if you’re going to try something similar, here’s some things I’d consider in retrospect: It wouldn’t be too much of a stretch to have the physical bike steer the direction of the virtual bike. Why not give the player total freedom to explore? Also, does the virtual bike have to be a bike? I’ll just leave this right here: http://goo.gl/fRWY6Z.

For the interested Makers out there, below is a schematic of the IR sensor along with the Arduino code. Tinker away!

Thank You so much on teaching us how it is done. Can you teach me how it works after the sensor gets reflection and measure the current speed? How did the sensor know I just stopped? Thank You in advance~

In my implementation, the sensor doesn’t actually calculate speed (I started with that approach but didn’t end with it). All it does is ping the mobile device each time it detects a reflection. The virtual bike applies a force forward and it has its own decay in speed. The sensor knows nothing about the fact that I’ve stopped, it just fails to ping the mobile device more. Here’s some psuedo-code to give you a hint:
Set IRLightPin to HIGH;
if (IRSensorPin == LOW) {
detectState = true;
if (detectState != lastDetectState) {
sendBlueToothMessageJustOnce();
lastDetectState = true;
}
}
else {
detectState = false;
lastDetectState = false;
}

hey i tried your program but its telling that
Arduino: 1.0.6 (Windows NT (unknown)), Board: “Arduino Uno”
sketch_dec13a.ino:1:10: error: #include expects “FILENAME” or
sketch_dec13a.ino:2:31: error: Adafruit_BLE_UART.h: No such file or directory
sketch_dec13a:12: error: variable or field ‘aciCallback’ declared void
sketch_dec13a:12: error: ‘aci_evt_opcode_t’ was not declared in this scope
sketch_dec13a:8: error: ‘Adafruit_BLE_UART’ does not name a type
sketch_dec13a.ino: In function ‘void setup()’:
sketch_dec13a:34: error: ‘uart’ was not declared in this scope
sketch_dec13a:37: error: ‘aciCallback’ was not declared in this scope
sketch_dec13a.ino: In function ‘void loop()’:
sketch_dec13a:44: error: ‘uart’ was not declared in this scope
sketch_dec13a.ino: At global scope:
sketch_dec13a:80: error: variable or field ‘aciCallback’ declared void
sketch_dec13a:80: error: ‘aci_evt_opcode_t’ was not declared in this scope

Dear Paul,
I am working with Prof. Steven LaValle to help obtain permissions for borrowing figures or pictures in his upcoming book Virtual Reality, to be published by Cambridge University Press. The book is online here:

Don’t forget you’ll need a bike, a stand, a phone, VR goggles, a computer to program the Arduino, soldering equipment.

I am constantly finding out I need something new along the way. I don’t think I’ve ever gotten my full list of parts ready up front ever. Just start and you’ll quickly realize what you’ll need along the way.

I’m not familiar with that component but it doesn’t look like the same sensor to me. I think this is just the sensor. You need to have an LED firing IR light so it can bounce off your reflective material to be received by the sensor.

I think you’ve only published part of the development and not everything complete. I do not think you’re generous, quite the contrary. I would prefer not to have found this project since I lost time investigating it and finally I discovered that you have published to us how the connection between the app and Arduino is made. You have not shared the app either.

If you’re already able to get the bike to move forward based on input from your sensor, you’re very close! In my implementation, each time I detected a rotation from the sensor, the Arduino sends a BLE message to the Unity app. When that BLE message is received, the Unity app applies a force to the bike – this is *not* the same thing as setting its velocity. Think of a force as a single PUSH forward, it will naturally decelerate over time if it doesn’t get additional pushes. So, if the input no longer detects rotations, it will no longer send messages and if no additional messages are received, the bike will naturally slow to a stop.

Hey Paul from Germany,
I am working on quite similar project. I have few problems related to that.:
1. I have captured the 360° video from my locality and now I want to use it in place of the 3D model. How can it be done? I am new to Unity
2. I have attached a motor to provide resistance and support to the rear wheel for the inclination and declination in the video. How could this be done? I have the complete data of the altitude of every point.