Introduction: Videogame Control Powered by Legs for PC

Special Thanks to Gabry295, to do the head control(https://www.instructables.com/id/Head-Mouse-With-MPU6050-and-Arduino-Micro/) and give me some inspiration to do this.

This is a project thinked for the people that have no arms, so i was thinking how improve their life quality, im a apassionate for videogames so i said, why dont make a videogame control for this people?.

Limitations: We can control the pc with a mouse and click function, and for videogames we have a function that works as the arrow keys, and the keys z,x,c,d.

The other limitations is that you need to configure every videogame to work with this configuration, you can use AutoHotkey to do this.

What we need:

1 Arduino Due

2 MPU- 6050

2 Buttons

2 Boxes

2 Bracelet

Wire

5 meters of thermofit

Extras:

A box to put the Arduino

And a Structure like the one of the image to put the bracelet's

Step 1: A Little Introduction to MPU-6050,I2C, and the Libraries That We Use

This is an introduction if you want to know more about the MPU-6050,communication and libraries for the project, you can jump this step.

MPU-6050

The InvenSense MPU-6050 sensor contains
a MEMS accelerometer and a MEMS gyro in a single chip. It is very accurate, as it contains 16-bits analog to digital conversion hardware for each channel. Therefor it captures the x, y, and z channel at the same time. The sensor uses the I2C-bus to interface with the Arduino.

The MPU-6050 is not expensive, especially given the fact that it combines both an accelerometer and a gyro.

For more information please go to :

https://playground.arduino.cc/Main/MPU-6050

For this project we use 2 MPU-6050, the comunnication between the Arduino Due and both MPU 6050 is made it via the I2C protocol, but we need different directions for every MPU, one on 0x69 and the other in 0x68, this do it, thanks to the PIN AD0, if you put 3.3v or ground in the pin AD0 this change the address.

I2C Comunnication Protocol

I2C combines the best features of SPI and UARTs. With I2C, you
can connect multiple slaves to a single master (like SPI) and you can have multiple masters controlling single, or multiple slaves. This is really useful when you want to have more than one microcontroller logging data to a single memory card or displaying text to a single LCD. Like UART communication, I2C only uses two wires to transmit data between devices:

SDA (Serial Data) – The line for the master and slave to send and receive data.
SCL (Serial Clock) – The line that carries the clock signal. I2C is a serial communication protocol, so data is transferred bit by bit along a single wire (the SDA line). Like SPI, I2C is synchronous, so the output of bits is synchronized to the sampling of bits by a clock signal shared between the master and the slave. The clock signal is always controlled by the master.

For more information please go to :

http://www.circuitbasics.com/basics-of-the-i2c-com...

In this project we use some libraries:

I2CDev.h

The I2C Device Library is a collection of uniform and well-documented classes to provide simple and intuitive
interfaces to an ever-growing collection of I2C devices. Each device is built to make use of the generic i2cdev code, which abstracts the I2C bit-level and byte-level communication away from each specific device class, making it easy to keep the device code clean while providing a simple way to modify just one class to port the I2C communication code onto different platforms (Arduino, PIC, simple bit-banging, etc.).

The I2Cdev code is built to be used statically, reducing the memory requirement if you have multiple I2C devices in your project. Only one instance of the I2Cdev class is required. For pure C or otherwise non-object-oriented platforms, a simple procedural version of the library is currently under development.

More Information:

https://www.i2cdevlib.com/

MPU6050.h

The MPU6050.h is a library for the read of data of the MPU, and set this, in this project we use some functions , if you want to know more about this you can go to the next link:

https://www.i2cdevlib.com/docs/html/class_m_p_u605...

wire.h

This library allows you to communicate with I2C
/ TWI devices. On the Arduino boards with the R3 layout (1.0 pinout), the SDA (data line) and SCL (clock line) are on the pin headers close to the AREF pin. The Arduino Due has two I2C / TWI interfaces SDA1 and SCL1 are near to the AREF pin and the additional one is on pins 20 and 21.

As a reference the table below shows where TWI pins are located on various Arduino boards.

BoardI2C / TWI pins

Uno, EthernetA4 (SDA), A5 (SCL)

Mega2560 20 (SDA), 21 (SCL)

Leonardo 2 (SDA), 3 (SCL)

Due 20 (SDA), 21 (SCL), SDA1, SCL1

As of Arduino 1.0, the library inherits from the Stream functions, making it consistent with other read/write libraries. Because of this, send() and receive() have been replaced with read() and write().

More Info:

https://www.arduino.cc/en/Reference/Wire

Mouse.h and Keyboard.h
This libraries is used to simulate keystrokes and the movement of the mouse.

Here is more info:

https://www.arduino.cc/en/Reference/MouseKeyboard

Step 2: Connections to the Arduino

Now we need to connect the arduino with the 2 mpu and the 2 buttons, for this i use a protoboard and the wire, first of all we need to connect and identify every wire connected in the protoboard, and then connect with the MPU.

Connections MPU:
Proto/Arduino-------- MPU1--------MPU2

PIN 20 SDA-------------SDA----------SDA

PIN 21 SCL-------------SCL-----------SCL

VCC---------------------- VCC---------- AD0

GND---------------------GND/AD0-----GND

Buttons Connection:
Proto/Arduino--------- Button 1------Button 2

PIN 36--------------------One side-------One side

PIN 37--------------------One side-------N/A

PIN 38--------------------N/A------------- One side

Deppends on your buttons you maybe need to see what side of the connection is the Normally open, and the normally closed, in any case you need to connect the PIN 36 in a normally open (i have a doubt about this, but i dont have this project on my hands, so later maybe i will fix this)

In any case, we have a image of the connections.

NOTE: Check the lenght of the wire connections between the protoboard and the 2 MPU-6050, because we need some lenght like 1 or 1.5 meters for using purpouses.

When you know that everything works well, you can put the thermofit in the wire to protect them.

Extra TIP:

As we are using the communication i2c, we need to braid the cable between, for example you can do the scl and vcc, and the other between gnd and sda for every MPU, this is for reduce the noise in the communication.(I read this in internet, so i recommend to do it)



Step 3: Arduino Programming

Now we need to connect the Arduino with the PC, remember to use the Programming Port, just download the code and program it.


Step 4: Building the Case

I bought two little box of plastic in my electronic store near to my house, this is for put in the MPU,we just need to make a hole and attach the MPU with two screws,use the following reference image to know how to put the MPU.

Now is time for the bracelets, we need to put together the box of plastic and the bracelet, for this i put a rivets between the box and the bracelet, but remember to make sure that the MPU is in the right position.

As an optional thing, we can put a little metal bar folded, as see on the image, this for put the device in a base.

Other optional things is to make a box for the buttons, and for the arduino, also you can do it a base to put the device there, imagine that you have some friend that can't put on the device, so you need to do something like a little base that helps to put on the dispositive.

Step 5: How It Works?

Before use the device, you need to connect the usb cable to the "Native port" of the Arduino.

Finally is time to use the videogame control, we have two "modes":

Mode 1: This is the default mode, with your left leg you control the arrows keys, if you move your leg to the front is the up key, if you move to the right is the right key, you move to the left is the left key, and if you move your leg to behind is the down key, Right leg, control the Z,X,C,D.

Mode 2: In this mode you can control the mouse with the left leg, and with the right leg you make a click, double click, and the right click.

Changing the mode: To change between the mode 1 and the mode 2, you need to keep pressed a few seconds one of the 2 buttons, for example if you want the mode 2 you need to press the button connected to the PIN 37.
for the mode 1 you need to press the button connected to the PIN 38.


Note: As i dont have the project right now, i dont remember exactly the function of the right leg, so i apologize for this, when i have the device i will fix this.


As you can see in the first and unique video, sometimes this device fail, is not for the sensor or another thing, the problem i think is in the mode of use, if you want to do this device let me give you a advice.

In the program we have some function like this:

//---------X axis-------------
if(accel_ang_xF > 20){ Keyboard.press(KEY_UP_ARROW); }

if(accel_ang_xF >= 0 && accel_ang_xF <= 19.9){ Keyboard.releaseAll();

}

if(accel_ang_xF < -20){ Keyboard.press(KEY_DOWN_ARROW); }


As you see the only time when all the arrows is released is when your leg is in the center, so remember to put in to the center, for release all keys, this apply to all modes.

Step 6: This Is My First Instructable

Hi to everyone, this is my first instructable so if you have any tip, please let me know, and other thing im learning english so maybe something is misspelled i appreciate if you let me know this.

If you have a doubt, a tip, or a question, you can write in the comments.

Comments

About This Instructable

276views

7favorites

License:

Bio: Im a Mechatronics Engineer
More by MagicKreator:Videogame Control Powered by Legs for PC
Add instructable to: