Introduction: Virtual Reality Suit Using Arduino

I have created this project to play normal computer games in full VR . This project emulates your movements into pressing or holding the keys of your keyboard

Example- when you move forward the action of pressing the key 'w' is emulated .

I have emulated the game Call of Duty 4: Modern Warfare but don't choose games that have recoil while shooting because it will change the default position of the mouse

Step 1: Requirements

Requirements are-

There is a list full of things you need to make this suit

Touch sensors-5

Force sensor-1

GPU 6050 - 4

(or)

GPU 6050 - 2 & Accelerometer - 2

Vr glasses

Vr enabled phone

PC

WiFi hotspot

A toy gun

A pc game( i have used Call of Duty- Modern Warfare 1)

Bread board wires (Male-Female )

ARDUINO LEONARDO-2

Auton sheild - 2

Power source (lipo)

Rainbow wires

Step 2: HARDWARE

*reload_pin,shoot_pin,night vision_pin,grenade_pin,weapon change_pin are touch sensors. aim_pin is force sensor and mouse is emulated by MPU6050 other sensors are accelerometer(posture,movement1&2)

1.1) SOLDERING

SOLDER MPU 6050, Accelerometer, Touch Sensor & force sensor with the wires

1.2) WIRING

For MPU 6050-

Pin 2- SDA

Pin 3- SCL

GND - GND

5v - PWR/VCC

For movement_pin1-

Pin A1- x axis

GND-GND

5v - PWR/VCC

For movement_pin2-

Pin A2- x axis

GND-GND

5v - PWR/VCC

For posture_pin-

Pin A0- x axis

GND-GND

5v - PWR/VCC

for weapon_pin –

sig-5v

GND-GND

5v - PWR/VCC

For Reload_pin –

pin12 – 5v

GND-GND

5v - PWR/VCC

For Nightvision_pin –

pin 10 – 5v

GND-GND

5v - PWR/VCC

For shoot_pin –

Pin7 – 5v

GND-GND

5v - PWR/VCC

For aim_pin –

Pin 8 – 5v

5v - PWR/VCC

1.3)SOLDERING WIRES

Solder the bread board wires with the rainbow wires

1.4) INSULATION

Tape the wires with the insulation tape on the place where you have soldered to avoid short circuits

Step 3: SOFTWARE

I have used an app called 'Remotr' from Play store to cast the video from the laptop to the phone

2.1) REMOTR-

Install REMOTR application to your computer and create an account

Here is the link-

http://remotrapp.com/#download

Install REMOTR app in your smartphone

2.2) VIDEO STREAMING

First connect both the computer and the same WiFi network and enter your REMOTR account in both the devices

now manually add the game which you want to stream in the software

now the app will show the computer as admin click it to start streaming

To stream in VR enable vr mode in your smartphone

If you can't understand Check this link for detailed information

http://remotrapp.com/en/howto

Step 4: MAIN CODE

The code for this project is not tough or complex but a long one

Here is the code just copy it and paste it in your arduino file

ARDUINO

LEONARDO Mouse-

I have reffered Gabry295. This mouse code is based on his head Mouse instructable

#include

#include

#include

#include

int aim_pin;

int shoot_pin;

MPU6050 mpu;

int16_t ax, ay, az, gx, gy, gz;

int vx, vy;

void setup() {

Serial.begin(9600);

Mouse.begin();

Wire.begin();

mpu.initialize();

if (!mpu.testConnection()) {

while (1);

}

pinMode(7,INPUT);

pinMode(8,INPUT);

}

void loop() {

shoot_pin = digitalRead(7);

aim_pin = digitalRead(8);

mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

vx = (gx-300)/200; // I have put -300 and +490 as my mpu6050 show these values when not moving check

vy = -(gz+490)/200; // check the code of head mouse by Gabry295 for more details on these values

Mouse.move(vx, vy);

delay(20);

while(shoot_pin == HIGH);

{

Mouse.click();

}

while(aim_pin == HIGH);

{

Mouse.click();

}

}

Leonardo Keyboard-

#include

int Grenade;

int weapon_pin;

int reload_pin;

int movement1_pin;

int movement2_pin;

int posture_pin;

char nightvision_pin;

void setup()

{

pinMode(7,INPUT);

pinMode(8,INPUT);

pinMode(9,INPUT);

pinMode(10,INPUT);

pinMode(11,INPUT);

pinMode(12,INPUT);

pinMode(A0,INPUT);

pinMode(A1,INPUT);

Keyboard.begin();

}

void loop()

{

Grenade_pin=digitalRead(8);

weapon_pin = digitalRead(9);

movement1_pin = analogRead(A1);

movement2_pin = analogRead(A2);

posture_pin = analogRead(A0);

reload_pin = digitalRead(12);

nightvision_pin = digitalRead(10);

if(grenade==HIGH)

{

Keyboard.press('g');

}

while (weapon_pin == HIGH)

{

Keyboard.press('q');

}

while(reload_pin == HIGH)

{

Keyboard.press('r');

}

while (movement1_pin>340&&movement1_pin<420)

{

Keyboard.press('w');

}

while (movement1_pin>420)

{

Keyboard.press('w');

Keyboard.press('p');

}

while (movement2_pin>340&&movement2_pin<420)

{

Keyboard.press('w');

}

while (movement2_pin>420)

{

Keyboard.press('p');

Keyboard.press('w');

}

while (posture_pin>340&&posture_pin<420)

{

Keyboard.press('c');

}

while (posture_pin>420)

{

Keyboard.press('l');

}

while (posture_pin<340)

{

Keyboard.press('z');

}

while (nightvision_pin==HIGH)

{

Keyboard.press('n');

}

}

}

Step 5: TEST CODES

Here are the few codes divided from the main code according to the
function

SHOOTING-

#include

int x;

void setup() {

pinMode(8,INPUT);

Mouse.begin();

}

void loop() {

x=digitalRead(8);

if(x==HIGH)

{

Mouse.click('g’);

}

}

AIMING-

#include

#include

#include

#include

MPU6050 mpu;

int16_t ax, ay, az, gx, gy, gz;

int vx, vy;

void setup() {

Serial.begin(9600);

Mouse.begin();

Wire.begin();

mpu.initialize();

if (!mpu.testConnection()) {

while (1);

}

}

void loop() {

shoot_pin = digitalRead(7);

aim_pin = digitalRead(8);

mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);

vx = (gx+300)/200; // "+300" because the x axis of gyroscope give values about -350 while it's not moving. Change this value if you get something different using the TEST code, chacking if there are values far from zero.

vy = -(gz_-100)/200; // same here about "-100"

RELOADING-

#include

int x;

void setup() {

pinMode(8,INPUT);

Keyboard.begin();

}

void loop() {

x=digitalRead(8);

if(x==HIGH)

{

Keyboard.press('r');

}

else

{

Keyboard.release('r');

}

}

NIGHT VISIO #include

int x;

void setup() {

pinMode(8,INPUT);

Keyboard.begin();

}

void loop() {

x=digitalRead(8);

if(x==HIGH)

{

Keyboard.press('g’);

}

else

{

Keyboard.release('g');

}

}

CROUCH AND PRONE-

#include

int y;

void setup() {

pinMode(A0,INPUT);

Serial.begin(9600);

}

void loop() {

y=analogRead(A0);

if(y<260)

{

Keyboard.release('c');

Keyboard.release('p');

}

else if(y>260&&y<310)

{

Keyboard.press('c');

}

else if(y>310)

{

Keyboard.press('p');

}

}

Step 6: GAME CONTROLS

change the game controls as follows

crouch - x

prone - l

weapon change - q

sprint - p

stand/jump - z

night vision - n

forward movement - w

grenade - g

Step 7: SETTING UP

Finally we have come to the last step now put the arduino

boards in a box and slip it into the bag

Now connect the micro USB of the arduino to the USB ports of laptop now connect the sensors as directed above

*arrow marks in the above pictures represents the direction the sensor must face


If you have any doubts don't hesitate to leave a comment and don't forget to share your experience

That's it thank you and

BYE.

Microcontroller Contest 2017

Participated in the
Microcontroller Contest 2017