Introduction: Gesture Controlled Gaming

Hi friends, In this instructable I will show you how to make a gesture controlled gaming with a Arduino UNO without getting into lot of stuff(like getting Arduino into DFU programmer mode or custom drivers or things like that).

I tried some games to check the compatibility of the system I find it is not compatible with NFS and GTA and I find my program stops responding when the game is loaded.

Here I used the serial input and then used a c# program to convert the serial inputs to keystrokes. Even though some Arduino models like Arduino Micro, Leonardo, etc comes with inbuilt capabilities for emulating as a keyboard or a mouse but unfortunately our Arduino UNO does not come with that feature.

I have googled "How to emulate a keyboard using Arduino" but the results are too annoying and it says to get into DFU programmer mode and install a driver and then you can emulate UNO as a Keyboard.

Here I can give you a pretty simple solution for this. In this I used the Serial input from the Arduino to control the game. I just converted the inputs to Keypress and played the game with it.

Step 1: Setup Your Arduino

Here for simplicity sake I used a ultrasound rangefinder module(HC-SR04) to get the inputs. You may use sensors like Accelerometer(like ADXL330) or any other module to get better gaming experience.

The circuit diagram is shown above for our HC-SR04 module. I also used some leds to know the status and toggle switch to control the input.

The major drawback with this system is your mouse pointer become unresponsive if you try to input at faster rates.So I used the toggle switch and some LED indicators to know the status of the system.

A simple diagram showing how to connect the ultrasound module is also provided. To get better control over your mouse pointer I recommend you to use a switch to stop and start the entire process in the Arduino.

I had calibrated the arduino to work within 60 cms

The arduino sketches for this project is also right here..

#define echoPin 7
#define trigPin 8 int ld = 0; void setup() { Serial.begin(9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); } void loop() { digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW); int distance = pulseIn(echoPin, HIGH) / 58.2;

int del = 0;

if (distance > 60) { Serial.println("p|39");//p|39 = p for press and r for release (39 - keycode for right arrow) del = distance - ld; delay(200); Serial.println("r|39"); return; } else if (distance < 15) { Serial.println("p|37"); delay(200); Serial.println("r|37"); return; } if ( ld - 1 > distance) { Serial.println("p|37"); del = ld - distance; delay(del * 25); Serial.println("r|37"); } else if (ld + 1 < distance) { Serial.println("p|39"); del = distance - ld; delay(del * 25); Serial.println("r|39"); } ld = distance; delay(10); }

Actually the sketches seems simpler the time delays and some other statements are provided there for better calibration for the game.

Step 2: Set Up Your PC

Next is to program your PC to listen to the COM port which the Arduino is connected. In windows systems you can find it in your device manager. You can download the C# program which I used to convert the serial inputs to keystrokes form my Github here.

Then open up the program and specify your COM port and the baud rate (here it is 9600). Then load your game and start to play then press the start button. Now you can play your games from Arduino UNO.

Arduino All The Things! Contest

Participated in the
Arduino All The Things! Contest