A project bundle demonstrating how to use an MPU-6050 accelerometer and gyroscope sensor.
This is a collection of projects demonstrating how to use data from a GY-521 breakout board in an external program.
It's intended to be a minimal-code example using the Digital Motion Processor (DMP) functionality available in the I2C Device Library.
More information about MPU-6050/GY-521 can be found on Arduino Playground.
- Arduino IDE
- Godot 3.5.1 Mono
- I2C Device Library
- An Arduino (tested on Uno and Leonardo)
- A GY-521 breakout board
- Enough 4-wire ribbon cable to connect the breakout board to the Arduino
- Download the i2cdevlib repository.
- From the
Arduino
folder, copyI2Cdev
andMPU6050
into your Arduino IDElibraries
folder. - Open the Arduino
GY521Server
project, and upload to your device.
Ensure that the SDA (data) and SCL (clock) pins of the breakout board are connected to the appropriate pins on the Arduino. For Uno, these are A4 (SDA) and A5 (SCL). For Leonardo, use pins 2 (SDA) and 3 (SCL).
The project uses a baud rate of 19200
by default. Each set of Euler angles are given in radians as follows:
@ <psi> <theta> <phi>\r\n
This is an example of serial monitor output:
Starting
Ready
@ -0.10 0.01 -0.03
@ -0.08 0.00 -0.02
@ -0.06 0.00 -0.02
@ -0.04 -0.00 -0.02
@ -0.02 -0.00 -0.01
@ 0.02 -0.01 -0.01
@ 0.04 -0.02 -0.00
@ 0.07 -0.02 0.00