-
Notifications
You must be signed in to change notification settings - Fork 1
/
iu_mpu_2.ino
32 lines (32 loc) · 1.06 KB
/
iu_mpu_2.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<Wire.h>
const int MPU6050_addr=0x68;
int16_t AccX,AccY,AccZ,Temp,GyroX,GyroY,GyroZ;
void setup(){
Wire.begin();
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600);
}
void loop(){
Wire.beginTransmission(MPU6050_addr);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU6050_addr,14,true);
AccX=Wire.read()<<8|Wire.read();
AccY=Wire.read()<<8|Wire.read();
AccZ=Wire.read()<<8|Wire.read();
Temp=Wire.read()<<8|Wire.read();
GyroX=Wire.read()<<8|Wire.read();
GyroY=Wire.read()<<8|Wire.read();
GyroZ=Wire.read()<<8|Wire.read();
Serial.print(AccX);
Serial.print(" "); Serial.println(AccY);
//Serial.print(" || AccZ = "); Serial.println(AccZ);
//Serial.print(" || Temp = "); Serial.print(Temp/340.00+36.53);
//Serial.print(" || GyroX = "); Serial.print(GyroX);
//Serial.print(" || GyroY = "); Serial.print(GyroY);
// Serial.print(" || GyroZ = "); Serial.println(GyroZ);
delay(100);
}