Introduction: Motion Controled Minecraft Using MPU 6050 and Raspberry Pi

In this Instructable, I'll be showing how to control Minecraft on the Raspberry Pi using an MPU 6050 motion controller. We will be using the python-minecraft API present by default on the Raspbian OS.

Step 1: Watch This Video to Have an Idea of What We Will Be Achieving.

Step 2: Parts List

The following are necessary:

1) Raspberry PI (Any Model)

2) Peripherals: Monitor, Keyboard and Mouse

3) micro/SD card with Raspbian installed (Refer here)

4) 4x Female to Female Jumper cables

5) MPU 6050 3.3v Module (Refer Here)

Step 3: Hardware Connections

Note: Please Double check the connections, as wrong connects might blow stuff up and let the magic smoke escape.

Connecting the sensor
To connect the sensor you need to use the GPIO pins on the Pi, the important pins are

Refer to Raspberry Pi Pin-out Here

  • Pin 1 - 3.3V connect to VCC
  • Pin 3 - SDA connect to SDA
  • Pin 5 - SCL connect to SCL
  • Pin 6 - Ground connect to GND

Step 4: Setup Software

Setting up the software side of things:

  1. Enable 12c to interact with MPU 6050
    • Open Terminal and type the following command:
      sudo raspi-config
    • Navigate to
      Advanced Option
    • Select and Enable i2c

Check whether the MPU 6050 has been detected:

Once you have the board connected you can test to see if the Pi has detected it.

  • This is done with the following command to install the i2c tools
    sudo apt-get install i2c-tools
  • Then either
    sudo i2cdetect -y 0
    (for a Revision 1 board like mine) or
    sudo i2cdetect -y 1
    (for a Revision 2 board)

Then you should see output showing any I2C devices that are attached and their addresses:

 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

This shows that the Pi has detected the sensor with an address of 0x68 (hexadecimal), this address is needed to interact with it.

Step 5: Get the Code

Download the open source code and dependency:

In a terminal window type the following codes:

git clone  http://github.com/ric96/motioncraft
sudo apt-get install python-smb

Step 6: Lets Make It Work

Finally to make everything work:

  1. Open Minecraft from the Menu.
  2. Open a terminal.
  3. On minecraft
    • Click on "Start Game"
    • Click on "Create New"
    • Wait for it to finish loading.
  4. On Terminal tyme the following code:
    • cd motioncraft
    • python motioncraft.py

Finally the Minecraft window should say hello world and moving the motion sensor should move the player as well !!!

Sensors Contest 2016

Participated in the
Sensors Contest 2016

First Time Author Contest 2016

Participated in the
First Time Author Contest 2016