Virtual Reality Skateboard With Arduino

The app can be found on the Google Play Store and its called "Arduino VR Skateboard". This is a really easy project that can be done in about an hour. It is more of a virtual reality experience rather than a game. An accelerometer/gyro goes onto an Arduino board and transmits the angular motion of the board via bluetooth to a (extremely amateur game) I made in Unity for Android phones. This only works for Android phones and your phone must be compatible with Google Cardboard. So, if you have an old skateboard laying around, turn it into a virtual reality skateboard. Here's how:

Full Text Instructions can be found here: Virtual Reality Skateboard

The app can be found on the Google Play Store and its called "Arduino VR Skateboard".

You will need:

A Google Cardboard style virtual reality headset.

A skateboard.

4 tennis balls (to keep from rolling away)

An Arduino Leonardo (or Uno)

Some jumper wires

A mini breadboard

An HC-06 bluetooth module

An MPU-6050 accelerometer/gyro

A 9V battery with battery box that has a on/off switch and a barrel plug (to power the Arduino board)

A soldering iron and maybe a hot glue gun


#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
    #include "Wire.h"
#endif

MPU6050 mpu;

   bool sendLeft = true;
   bool sendRight = true;
   bool sendJump = true;
   bool sendCenter = true;

bool dmpReady = false;  
uint8_t mpuIntStatus;   
uint8_t devStatus;     
uint16_t packetSize;    
uint16_t fifoCount;     
uint8_t fifoBuffer[64]; 


Quaternion q;           
VectorInt16 aa;        
VectorInt16 aaReal;     
VectorInt16 aaWorld;    
VectorFloat gravity;    
float euler[3];         
float ypr[3];           
volatile bool mpuInterrupt = false;  

void setup() 
{
 
    #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
        Wire.begin();
        TWBR = 24; 
    #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE
        Fastwire::setup(400, true);
    #endif

    Serial.begin(9600);  //For use with Arduino Uno
    Serial1.begin(9600); //For use with Leonardo

    Serial.println(F("Initializing I2C devices..."));
    mpu.initialize();

    Serial.println(F("Testing device connections..."));
    Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));
    Serial.println(F("Initializing DMP..."));
    devStatus = mpu.dmpInitialize();

    mpu.setXGyroOffset(220);
    mpu.setYGyroOffset(76);
    mpu.setZGyroOffset(-85);
    mpu.setZAccelOffset(1788); 
    if (devStatus == 0) {
        Serial.println(F("Enabling DMP..."));
        mpu.setDMPEnabled(true);
        Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)..."));
        attachInterrupt(0, dmpDataReady, RISING);
        mpuIntStatus = mpu.getIntStatus();
        Serial.println(F("DMP ready! Waiting for first interrupt..."));
        dmpReady = true;
        packetSize = mpu.dmpGetFIFOPacketSize();
    } else {
        Serial.print(F("DMP Initialization failed (code "));
        Serial.print(devStatus);
        Serial.println(F(")"));
    }
   
}


void loop() 
{
  
    if (!dmpReady) return;
    mpuInterrupt = false;
    mpuIntStatus = mpu.getIntStatus();
    fifoCount = mpu.getFIFOCount();
    if ((mpuIntStatus & 0x10) || fifoCount == 1024) {
        mpu.resetFIFO();
        Serial.println(F("FIFO Overflow"));

    } else if (mpuIntStatus & 0x02) {
        while (fifoCount < packetSize) {
          fifoCount = mpu.getFIFOCount();
        }
        mpu.getFIFOBytes(fifoBuffer, packetSize);        
        fifoCount -= packetSize;
        mpu.dmpGetQuaternion(&q, fifoBuffer);
        mpu.dmpGetGravity(&gravity, &q);
        mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
        
        int x = ypr[0] * 180/M_PI;
        int y = ypr[1] * 180/M_PI;
        int z = ypr[2] * 180/M_PI;
        
   if (z >= 0){
      //backward
      if (sendJump){
      Serial1.write("b");
      Serial1.write(10);
      Serial.write("b");
      Serial.write(10);
      sendJump = false;
      }
      sendLeft = true;
      sendRight = true;
      sendCenter = true;
      
    } else if (y > 4){   //To make more sensitive change value to 4 or less
      //right
      if (sendRight){
      Serial1.write("r");
      Serial1.write(10);
      Serial.write("r");
      Serial.write(10);
      sendRight = false;
      }
      sendJump = true;
      sendLeft = true;
      sendCenter = true;
    } else if (y < -4){  //To make more sensitive change to -4 or greater 
      //left
      if (sendLeft){
      Serial1.write("l");
      Serial1.write(10);
      Serial.write("l");
      Serial.write(10);
      sendLeft = false;
      }
      sendJump = true;
      sendRight = true;
      sendCenter = true;

    } else if (y >= -3 || y <= 3){
      //center
      if (sendCenter == true){
          Serial1.write("c");
          Serial1.write(10);
          Serial.write("c");
          Serial.write(10);
          sendCenter = false;
      }
      
      sendJump = true;
      sendLeft = true;
      sendRight = true;
    }   
        
       
    }
}

void dmpDataReady() 
{
    mpuInterrupt = true;
}


Hey !!!

about us (me).

My name is Matthew, I am 26, and I attend the University of Pittsurgh. Currently I am a Senior, going for a bachelors in Information Science with a minor in Computer Science. I am always looking for someone that would like to embark on a new project or startup. I work as a food server when I am not at school, but would love something a little more technical, if anyone is hiring.

  • Pittsburgh, PA
  • MatthewHallberg@gmail.com

This form is no longer hooked up! Just send me an email!