//#include <Adafruit_MPU6050.h>
//#include <Adafruit_Sensor.h>
//#include "Wire.h"
#include <MPU6050_tockn.h>
#include <Wire.h>

MPU6050 mpu6050(Wire);

int trig_pin=2;
int echo_pin=3;

int x, y, z;
float distance;

long getDistance(){
  digitalWrite(trig_pin,LOW);
  delayMicroseconds(2);
  digitalWrite(trig_pin,HIGH);
  delayMicroseconds(10);
  digitalWrite(trig_pin,LOW);

  long duration = pulseIn(echo_pin, HIGH);

  long distanceCM = duration*0.034/2;
  return distanceCM;
}

void setup(void) {
  Serial.begin(9600);
  pinMode(trig_pin, OUTPUT);
  pinMode(echo_pin, INPUT);

  Wire.begin();
  mpu6050.begin();
  mpu6050.calcGyroOffsets(true);
  Serial.println(" ");


}

void loop() {
  mpu6050.update();

  distance=getDistance();

  x = mpu6050.getAngleX();
  y = mpu6050.getAngleY();
  z = mpu6050.getAngleZ();
  Serial.print("X: "); Serial.print(x); Serial.print("      ");
  Serial.print("Y: "); Serial.print(y); Serial.print("      ");
  Serial.print("Z: "); Serial.println(z);

  Serial.println(distance);

  Serial.println("-----------------------------------------"); 


 

  Serial.println("");
  //delay(500);
}