This video tutorial goes over the installation and setup of a GY-521 board with a MPU6050 3 Axis Gyroscope and Accelerometer with an Arduino. After some initial troubleshooting with I was able to get the component working. At first I had trouble with loose breadboard connections so I decided to solder in the pins that came with the component. That solved my problem and I was off and running. I used some 3D modeling software to illustrate the operation of the component.

Everything you need to duplicate this project can be found here:


Step 1: Solder Pins to the Component

The component came with two sets of pins which I highly recommend soldering to the component.

I tried testing with a breadboard at first but only ran into frustration as the connections were loose. I was able to get a red led on the board so my voltage and ground were connected. However, when I ran my MPU6050 software on the Arduino, my serial monitor would show the error message: "MPU6050 connection failed". Soldering the pins to the board solved the connection issue. So if you are having this error message and are using a breadboard, solder could solve the problem.

Step 2: Connect to Arduino

Now that you have your pins soldered to the component you can wire it up to the Arduino Uno.

VCC -> 5v


SCL -> A5

SDA -> A4

INT -> D2 (used for interrupt)

(the other pins do not need to be connected)

Step 3: Use I2C Scanner and MPU6050 Arduino Software

Using I2C Scanner, verify that the Arduino finds the device.

If the device is found then try using the MPU6050 example software to see if you get raw data.

The MPU6050 libraries can be downloaded here: http://diyhacking.com/projects/MPU6050.zip

The I2C libraries can be downloaded here: http://diyhacking.com/projects/I2Cdev.zip

Note: if the output is random characters, make sure your serial connection is set to 9600 baud in the arduino setup.

Step 4: Run the MPU Teapot Example With Processor IDE

Download and install the Processor IDE.

You can download the Processor IDE here: https://processing.org/download/?processing

Then open the MPU Teapot example and change some code.


And uncomment the line: //#define OUTPUT_TEAPOT

will look like this:




You will also need to change some lines of code for the Arduino MPU6050 Teapot example:

String portName = “/dev/ttyUSB1”;.
Change "ttyUSB1" to the port where your Arduino is connected. eg. "COM3";

I had some trouble finding the Toxiclabs library needed for this demo but I eventually found it here: https://bitbucket.org/postspectacular/toxiclibs/do...

You will need to modify some lines of code as detailed here:


Have Fun!

<p>hi i need the code of the MPU6050 for arduino Due. </p>
<p>i need help and ive seen your gyro led project, and its awesome and easy. can you instead of gyro, use the accelerometer values? example if accelx value is 2000-2500 led 1 lights up, value 2500-3000 led 1&amp;2 lights up and so on. could you help? thanks alot! </p><p>PS: i only need 1 accelerometer value, either x/y value.</p>
<p>Hello, I am making a self balancing vehicle for my final year project using an MPU 6050, a Genuino board (might be a counterfeit), and a Cytron duo motor driver. </p><p>However I am encountering a problem. The gyro sometimes starts giving out random absurd values and at times stops communicating. Do you think a problem with the MPU or the Arduino?</p>

About This Instructable




Bio: Will write code for food. :) If you need help with any of your embedded Arduino applications please send me a message.
More by dmainmon:ArduCAM Mini ESP8266 Web Camera ESP8266-12E DHT Thermostat ESP8266 OLED Clock IoT Using AJAX 
Add instructable to: