SHARE
TWEET

Untitled

a guest Dec 8th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<Wire.h>
  2. const int MPU_addr=0x68;
  3. int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
  4. void setup(){
  5.   Wire.begin();
  6.   Wire.beginTransmission(MPU_addr);
  7.   Wire.write(0x6B);  
  8.   Wire.write(0);    
  9.   Wire.endTransmission(true);
  10.   Serial.begin(9600);
  11. }
  12. void loop(){
  13.   Wire.beginTransmission(MPU_addr);
  14.   Wire.write(0x3B);  
  15.   Wire.endTransmission(false);
  16.   Wire.requestFrom(MPU_addr,14,true);
  17.   GyX=Wire.read()<<8|Wire.read();  
  18.   GyY=Wire.read()<<8|Wire.read();  
  19.   GyZ=Wire.read()<<8|Wire.read();  
  20.   Serial.print(" | GyX = "); Serial.print(GyX);
  21.   Serial.print(" | GyY = "); Serial.print(GyY);
  22.   Serial.print(" | GyZ = "); Serial.println(GyZ);
  23.   delay(333);
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top