What do you get when combining a wetsuit glove, resistors, a gyroscope, and an Arduino?










Towards the end of my first year at university (April 2017), I made a glove that a player could wear and use in order to play a simple game.

The glove was made from a wetsuit glove, some flexible resistors (the resistances of which vary dependant upon how bent they are), a gyroscope, and an Arduino.

The Arduino processed the data from the glove and sent it to the computer playing the game.

I used an MPU650 gyroscope, and found an incredibly useful sketch file by Jeff Rowberg for interpreting the data it outputs. Rowberg licensed it under the MIT license, so I modified it to suit my needs, adding in support for the resistors, and adding chars to identify each bit of data. (I added the chars as without them it would be harder for me to know which bit of data corresponds to which sensor; without chars it was just a string of numbers.)

Extract from .ino sketch file


        // Should clear left over info

        // display Euler angles in degrees
        mpu.dmpGetQuaternion(&q, fifoBuffer);
        mpu.dmpGetGravity(&gravity, &q);
        mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
  // this is where we add chars to the yaw/pitch/roll outputs
        Serial.println(ypr[0] * 180/M_PI);
        Serial.println(ypr[1] * 180/M_PI);
        Serial.println(ypr[2] * 180/M_PI);

  // and the chars alongside my resistor outputs

I then had all the data sent via serial port to Unity, where I had written a C# script that separated the string of data using those chars, and sent the data to an input manager. The input manager could then be accessed by game-related scripts in order to play. (Shown below)

Extract from ‘ReadStream.cs’

void ProcessReading(string reading)
    // First character of line represents the relevant sensor.
    // Other characters after the first represent the actual value.
    char sensor = reading[0];
    string value = reading.Substring(1);

    // Assign values to their corresponding variables.
    switch (sensor)
        case 'F':
            f1Value = int.Parse(value);       
        case 'S':
            f2Value = int.Parse(value);  
        case 'P':
            pitch = float.Parse(value);
        case 'Y':
            yaw = float.Parse(value);
        case 'R':
            roll = float.Parse(value);

There were loads of other peripheral issues I had to deal with, including measuring and creating offsets for each of the resistors, as they had a +/-30% precision. I also found that the gyroscope would sometimes act weird, and always in a different way, so I had to apply offsets at run time (which can be seen at the beginning of the below video, marked by a green tick.) Weirder still, the gyroscope inaccuracy only ever effected the yaw – to this day I have no idea why. Perhaps I had coded something incorrectly somewhere else.

Extract from ‘InterpretStream.cs’

public ReadStream readStream;
public GyroOffsets gyroOffsets;

public int f1Offset = 100;  // offset for readings as resistors have +/- 30% precision
public int f2Offset = 157;

public void CalculateGyro()
    // Only need to apply offset to yaw as other readings are actually accurate.
    gyroP = readStream.pitch;
    gyroY = readStream.yaw + gyroOffsets.offsetY;
    gyroR = readStream.roll;

Here is a video of the finished project and game I made!