MPU6050 Orientation

Hello I am currently creating a project for a college class, long story short, I am trying to configure an Arduino Uno to use an MPU6050 in order to control servo motors based on the orientation of the gyroscope. I am not great at coding so I have mostly reserved to looking for similar codes online making some changes to fit my project.

The problem I am facing is the fact that I will need to attach the MPU upside down, and I am struggling to figure out how exactly how to configure my code for my MPU to be oriented upside down. Based on those readings the servo motors will move accordingly. in order to account for any tilting of the gyroscope in order to keep it parallel to the ground.

I attached the code that I have found and been using, aside for minor alternations to the code in order to fit my project, I have not changed anything so it works more or less fine when MPU is upright.

I have attempted to research in the offset of the gyroscope as I believed that to be the key to my problem however with no luck. The lines of the offset in the code are:

mpu.setZAccelOffset(1688); // 1688 factory default for my test chip

Any help will be greatly appreciated, Thank You.

PS. There is another problem with the code I am facing however my current concern is to orient the MPU to read the coordinates upside down.

WorkingControls.ino (5.27 KB)

"orientation of the gyroscope" --> it's totally irrelevant how the mpu6050 is oriented. The rest I cannot comment, it's unclear what you actually want to accomlish.

If I understand you correctly, all you have to do is a simple *(-1) multiplication. Usually on MPU6050 boards there are arrows which point in the direction of each axis.

Sorry I realized that my idea is hard to explain, I figured it out in the end, just needed to use a bunch of if else statements, but thank you for the replies! The Other problem I am facing though is the program keeps resetting, I am assuming due to the interrupts. Will try to figure out myself but quite likely will return to this forum for some help =D