Skip to content

CodeAndCircuits/MPU6050-Arduino-Tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 

Repository files navigation

MPU6050 Arduino Tutorial

This project demonstrates how to use the MPU6050 6-axis motion sensor with Arduino.

🧠 Features

  • Reads Accelerometer (X, Y, Z)
  • Reads Gyroscope (X, Y, Z)
  • Uses I2C Communication
  • Displays data in Serial Monitor

πŸ”Œ Wiring

MPU6050 β†’ Arduino Uno VCC β†’ 5V GND β†’ GND SDA β†’ A4 SCL β†’ A5

πŸ“š Used In

  • Drones
  • Self-balancing robots
  • Motion tracking systems

Created by Code and Circuits πŸš€

the code for the mpu6050 πŸ‘‡πŸ‘‡

#include <Wire.h>

const int MPU_addr = 0x68; // I2C address of MPU6050

int16_t AcX, AcY, AcZ, GyX, GyY, GyZ;

void setup() { Wire.begin(); Wire.beginTransmission(MPU_addr); Wire.write(0x6B); // Power management register Wire.write(0); // Wake up MPU6050 Wire.endTransmission(true);

Serial.begin(9600); }

void loop() { Wire.beginTransmission(MPU_addr); Wire.write(0x3B); // Starting register for accel data Wire.endTransmission(false); Wire.requestFrom(MPU_addr, 14, true);

AcX = Wire.read() << 8 | Wire.read(); AcY = Wire.read() << 8 | Wire.read(); AcZ = Wire.read() << 8 | Wire.read(); Wire.read(); Wire.read(); // Skip temperature GyX = Wire.read() << 8 | Wire.read(); GyY = Wire.read() << 8 | Wire.read(); GyZ = Wire.read() << 8 | Wire.read();

Serial.print("Accel: "); Serial.print(AcX); Serial.print(" "); Serial.print(AcY); Serial.print(" "); Serial.print(AcZ);

Serial.print(" | Gyro: "); Serial.print(GyX); Serial.print(" "); Serial.print(GyY); Serial.print(" "); Serial.println(GyZ);

delay(500); }

About

MPU6050 motion sensor Arduino example - Code and Circuits

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors