The InvenSense MPU6050 is a highly integrated 6-axis motion tracking device that combines a 3-axis gyroscope and a 3-axis accelerometer on a single chip. It is widely used in various applications such as gaming devices, mobile phones, and more sophisticated motion-based applications like drones and wearable technology.
Pin Number | Name | Description |
---|---|---|
1 | VCC | Power supply (2.3V – 3.4V) |
2 | GND | Ground |
3 | SCL | I2C clock line |
4 | SDA | I2C data line |
5 | XDA | Auxiliary data for external sensors |
6 | XCL | Auxiliary clock for external sensors |
7 | AD0 | Address pin for I2C address selection |
8 | INT | Interrupt output |
#include <Wire.h>
#include <MPU6050.h>
MPU6050 mpu;
void setup() {
Wire.begin();
Serial.begin(9600);
Serial.println("Initialize MPU6050");
while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_16G)) {
Serial.println("Could not find a valid MPU6050 sensor, check wiring!");
delay(500);
}
}
void loop() {
// Read normalized values
Vector normAccel = mpu.readNormalizeAccel();
Vector normGyro = mpu.readNormalizeGyro();
// Print the values on Serial Monitor
Serial.print("Accel X: "); Serial.println(normAccel.XAxis);
Serial.print("Accel Y: "); Serial.println(normAccel.YAxis);
Serial.print("Accel Z: "); Serial.println(normAccel.ZAxis);
Serial.print("Gyro X: "); Serial.println(normGyro.XAxis);
Serial.print("Gyro Y: "); Serial.println(normGyro.YAxis);
Serial.print("Gyro Z: "); Serial.println(normGyro.ZAxis);
delay(100);
}
Note: This example assumes the use of the MPU6050
library, which provides functions for easy communication with the MPU6050 sensor. Ensure that the library is installed in your Arduino IDE before uploading the code to the Arduino UNO.
Comments in the code are wrapped to limit line length to 80 characters for readability.
This documentation provides a comprehensive guide to the InvenSense MPU6050 sensor module, covering technical specifications, usage instructions, and troubleshooting tips. It is designed to assist users of all levels in integrating this sensor into their projects effectively.