Mturk Jobs

Mturk Jobs
Mturk Jobs

Tank

Thursday, March 22, 2018

Arduino MPU6050 Gyroscope Accelerometer - GY521 MOU6050

In this post, I’ll show you how to read data from the MPU6050.

This is an integrated MEMS Accelerometer and Gyroscope unit that is so popular and can be easily attached to Arduino.

The unit uses I2C protocol.

In the first example from Arduino website, we can read data and show it on the serial monitor application in Arduino IDE.

In the second project, you can read data from the unit and view data on Processing.



Project #1

This project is brought to you from Arduino create website.


Project Schematics:


GY-521                                           Arduino
VCC                    ->                  3.3 V or 5 V 
GND                    ->                           GND
SCL                           ->                       A5
SDA                      ->                       A4
XDA ->                No Connection
XCL ->               No Connection
ADO ->               No Connection

INT ->               No Connection





Here is the code for the project:


#include
const int MPU=0x68; 
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

void setup(){
  Wire.begin();
  Wire.beginTransmission(MPU);
  Wire.write(0x6B); 
  Wire.write(0);    
  Wire.endTransmission(true);
  Serial.begin(9600);
}
void loop(){
  Wire.beginTransmission(MPU);
  Wire.write(0x3B);  
  Wire.endTransmission(false);
  Wire.requestFrom(MPU,12,true);  
  AcX=Wire.read()<<8|Wire.read();    
  AcY=Wire.read()<<8|Wire.read();  
  AcZ=Wire.read()<<8|Wire.read();  
  GyX=Wire.read()<<8|Wire.read();  
  GyY=Wire.read()<<8|Wire.read();  
  GyZ=Wire.read()<<8|Wire.read();  
  
  Serial.print("Accelerometer: ");
  Serial.print("X = "); Serial.print(AcX);
  Serial.print(" | Y = "); Serial.print(AcY);
  Serial.print(" | Z = "); Serial.println(AcZ); 
  
  Serial.print("Gyroscope: ");
  Serial.print("X = "); Serial.print(GyX);
  Serial.print(" | Y = "); Serial.print(GyY);
  Serial.print(" | Z = "); Serial.println(GyZ);
  Serial.println(" ");
  delay(333);
}














Project #2

And as another source of a project using the same unit GY-521, here it is:

You can download Arduino code, connect the project, get Processing code and then run it on http://sketchpad.cc


Project Schematics is just the same as the previous project. I repeated them to make things easy:



GY-521                                           Arduino
VCC                    ->                  3.3 V or 5 V 
GND                    ->                           GND
SCL                           ->                       A5
SDA                      ->                       A4
XDA ->                No Connection
XCL ->               No Connection
ADO ->               No Connection

INT ->               No Connection



Get Arduino Code from here

Get Processing Code from here









Paid Online Surveys

Check our books on Amazon we created on our way to find happiness.


A Trip To Siwa Oasis: Tourist guide to an Egyptian Oasis by [ElSakhawy, Sara M.]


A Trip To Siwa Oasis




The Ultimate travel bag list by [ Elskhawy, Sara M.]

















No comments:

Tank