amar axr
Published © GPL3+

Gesture Based Wireless Gaming Console

Project aim is to develop wireless gaming controller using Arduino, Xbee s2, accelerometer , bump switches and also also created 2D game.

IntermediateFull instructions provided2 hours4,290
Gesture Based Wireless Gaming Console

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Arduino Leonardo
Arduino Leonardo
×1
SparkFun xbee s2
×1
Analog Accelerometer: ADXL335
Adafruit Analog Accelerometer: ADXL335
×1
SparkFun Bump switchs
×1

Software apps and online services

Arduino IDE
Arduino IDE
xctu
Game editor
picassa
Paint
Adobe Photoshop

Hand tools and fabrication machines

Digital camera

Story

Read more

Custom parts and enclosures

REPORT

Complete Report PDF

Game editor

Game file which I have designed in game editor software.

Schematics

TX

TX schematic

Rx section

Rx schematic

Code

Tx code

Arduino
This code is for Arduino which is at Transmitter section
const int buttonPin = 6;   int buttonState = 0; 
const int buttonPin1 = 3;   int buttonState1 = 0; 
const int buttonPin2 = 4;   int buttonState2 = 0; 
const int buttonPin3 = 5;   int buttonState3 = 0; 
const int groundpin = 18;             // analog input pin 4 -- ground
const int powerpin = 19;              // analog input pin 5 -- voltage
const int xpin = A3;                  // x-axis of the accelerometer
const int ypin = A2;                  // y-axis
const int zpin = A1;                  // z-axis (only on 3-axis models ADXL335)
void setup()
{
  pinMode(13,OUTPUT);  pinMode(buttonPin, INPUT);  
  Serial.begin(9600); pinMode(groundpin, OUTPUT);
  pinMode(powerpin, OUTPUT);
  digitalWrite(groundpin, LOW); 
  digitalWrite(powerpin, HIGH);

}
void loop()
{
   buttonState = digitalRead(buttonPin);
   buttonState1 = digitalRead(buttonPin1);
   buttonState2 = digitalRead(buttonPin2);
      buttonState3 = digitalRead(buttonPin3);
       if( analogRead(ypin)>400){  // can use any direction
     Serial.println('5');
    delay(500);
  }
    if( analogRead(ypin)<300){  
     Serial.println('6');
    delay(500);
}
  if (buttonState == HIGH) {     
    Serial.println('1');
    delay(500);
  }

if (buttonState1 == HIGH) {     
    Serial.println('2');
    delay(500);
  }
  if (buttonState2 == HIGH) {     
    Serial.println('3');
    delay(500);
  }
  if (buttonState3 == HIGH) {     
    Serial.println('4');
    delay(500);
 
  }
  
}

RX section

Arduino
This code is for receiver arduino Leonardo
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup() { 

  Serial.begin(9600);

while (! Serial) {
  Keyboard.begin();mySerial. begin(9600);
}
}

void loop() {
  // use serial input to control the mouse:
  if (mySerial. available ()){

   int inChar = mySerial. read ();

    switch ( inChar) {   
    case '1':

     Keyboard.press('m'); delay(100);
     Keyboard.release('m');

      break; 
    case '2':

     Keyboard.press(KEY_LEFT_ARROW);Keyboard.press('s');delay(300);  Keyboard.release(KEY_LEFT_ARROW);Keyboard.release('S');
      break;
    case '3':
   
     Keyboard.press(KEY_RIGHT_ARROW);Keyboard.press('s');delay(300);  Keyboard.release(KEY_RIGHT_ARROW);Keyboard.release('S');
      break;
    case '4':
  
     Keyboard.press('s'); delay(500); Keyboard.release('S');
      break;
  case '5':
  
     Keyboard.press(KEY_RIGHT_ARROW); delay(500); Keyboard.release(KEY_RIGHT_ARROW);
      break;
       case '6':
  
     Keyboard.press(KEY_LEFT_ARROW); delay(500);Keyboard.release(KEY_LEFT_ARROW);
      break;
    }
  }
}

Credits

amar axr

amar axr

12 projects • 16 followers
Electronics and Communication engineer

Comments