Gaming Glove

by PushpendraC2 in Circuits > Arduino

899 Views, 12 Favorites, 0 Comments

Gaming Glove

Copy of THIS DIY DEVICE CAN TRACK ISS (3).png
Gaming Glove - Play Games using Hand Gestures 😎 #arduino #gaming

The gaming glove is a wearable controller featuring an MPU-6050 sensor mounted on top. By tilting your hand along the X-axis and Y-axis, you can trigger keypresses to control games. This project is perfect for playing running games like Subway Surfers, which use the A, S, D, and W keys for movement.

In this build, I've mapped the X-axis to the 'A' and 'D' keys, and the Y-axis to the 'W' and 'S' keys. While this tutorial covers four basic keys, the MPU-6050 sensor is capable of much moreβ€”feel free to use your creativity to add additional functionality and make it even more fun!

Supplies

Screenshot 2025-10-05 164027.png
  1. Arduino UNO (or any compatible prototyping board)
  2. MPU-6050 Module
  3. Arduino Programming Cable
  4. Glove
  5. Wires

Connect the MPU-6050 Module to Arduino

Gemini_Generated_Image_o2ek3to2ek3to2ek.png

Connect the Arduino UNO to the MPU-6050 sensor according to the wiring diagram shown in the image:

  1. VCC β†’ 5V
  2. GND β†’ GND
  3. SCL β†’ A5
  4. SDA β†’ A4

Ensure all connections are secure before proceeding to the next step.

Upload Code to Arduino

Upload the following code to your Arduino using the Arduino IDE:

#include<Wire.h>
uint8_t buf[8] = { 0 };

const int MPU_addr=0x68;
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

int minVal=265;
int maxVal=402;

double x;
double y;
double Xdiff;
double Ydiff;

bool runningX = true;
bool runningY = true;

void setup(){
Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600);
}
void loop(){
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true);
AcX=Wire.read()<<8|Wire.read();
AcY=Wire.read()<<8|Wire.read();
AcZ=Wire.read()<<8|Wire.read();
int xAng = map(AcX,minVal,maxVal,-90,90);
int yAng = map(AcY,minVal,maxVal,-90,90);
int zAng = map(AcZ,minVal,maxVal,-90,90);

x= RAD_TO_DEG * (atan2(-yAng, -zAng)+PI);
y= RAD_TO_DEG * (atan2(-xAng, -zAng)+PI);

Xdiff = (x<180)? x : (360-x);
Ydiff = (y<160)? (y+20):abs(340 - y);

if(x<5 || x>355){
runningX = true;
}
if(y < 345 && y > 335){
runningY = true;
}

if(Xdiff > Ydiff){

//When button representing W is pressed
if (x > 50 && x < 180 && runningX == true) {
buf[2] = 4; // A keycode
Serial.write(buf, 8); // Send keypress
// Serial.println("A");
releaseKey();
runningX = false;
}

//When button representing S is pressed
else if (x < 320 && x > 180 && runningX == true) {
buf[2] = 7; // D keycode
Serial.write(buf, 8); // Send keypress
// Serial.println("D");
releaseKey();
runningX = false;
}
}
else if(Xdiff < Ydiff){

//When button representing A is pressed
if (y > 10 && y < 160 && runningY == true) {
buf[2] = 22; // S keycode
Serial.write(buf, 8); // Send keypress
// Serial.println("S");
releaseKey();
runningY = false;
}

//When button representing D is pressed
else if (y < 310 && y > 160 && runningY == true) {
buf[2] = 26; // W keycode
Serial.write(buf, 8); // Send keypress
// Serial.println("W");
releaseKey();
runningY = false;
}
}
Xdiff = 0;
Ydiff = 0;
}

// Function for Key Release
void releaseKey()
{
buf[0] = 0;
buf[2] = 0;
Serial.write(buf, 8); // Send Release key
}

Convert Arduino Into an HID Device

Screenshot 2025-10-06 001717.png

The Arduino UNO and Nano boards cannot use the 'Keyboard' library natively for keypress actions because they lack the necessary USB HID capabilities. To enable this functionality, you need to flash the Arduino with modified firmware to convert it into an HID (Human Interface Device).

Instructions:

I've found a helpful YouTube tutorial that walks you through the firmware flashing process. You can follow it here.

Important: This process will temporarily change your Arduino's firmware. You can revert it back to the original firmware later if needed.

Install Subway Surfers or Any Runner Game

nfbghcxjhgfc.png
gjfkh.png

Install Subway Surfers or any runner game on your PC, or play it directly in your web browser from here.


Note: Make sure to bind the A, S, W, and D keys to the game's movement controls if they aren't already configured.

Gaming Glove Is Ready to Use!

ggt5.jpg
Screenshot_2024-11-30-22-07-36-78_99c04817c0de5652397fc8b56c3b3817.jpg

Congratulations! Your gaming glove is now complete and ready for action.

How to Use:

  1. Wear the glove with the MPU-6050 sensor securely attached
  2. Connect the Arduino to your computer via USB
  3. Launch your game
  4. Tilt your hand to control your character:
  5. Tilt left β†’ Move left (A key)
  6. Tilt right β†’ Move right (D key)
  7. Tilt forward β†’ Move forward (W key)
  8. Tilt backward β†’ Move backward (S key)

Enjoy playing with your custom-built gaming glove!


Conclusion


This project demonstrates how you can create a motion-controlled gaming interface using simple, affordable components. The MPU-6050 sensor opens up many possibilities for gesture-based controls, and this basic four-key setup is just the beginning.

Future Improvements:

  1. Add more keys for additional game actions
  2. Incorporate buttons for jump or special moves
  3. Create a wireless version using Bluetooth
  4. Add LED indicators for visual feedback
  5. Calibrate sensitivity for different hand sizes

Feel free to experiment and share your modifications. Happy gaming!