Hi. So I found a website that turns acceleration data into tilt angles: https://www.instructables.com/id/How-to-Measure-Angle-With-MPU-6050GY-521/
I'm wondering if anyone can explain how this is done? Namely, what's going on with the arduino map function and with the geometry/trigonometry? What formula is being used??
I want to use this code for a project except I want to understand what's going on first. I tried posting this in the math stack exchange but couldn't get an answer, so hopefully someone here can help!
Here's the code I use, which is basically the same as on the site except the method for getting the acceleration data:
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); int xAng = map(ax, minAcel, maxAcel, -90, 90); int yAng = map(ay, minAcel, maxAcel, -90, 90); int zAng = map(az, minAcel, maxAcel, -90, 90); //tilt angles double x = RAD_TO_DEG * (atan2(-yAng, -zAng) + PI); double y = RAD_TO_DEG * (atan2(-xAng, -zAng) + PI);