Self-Levelling Table

In my summer before first year, I started a business creating custom tables. Epoxy resin is one material that I used. To use resin, you need to pour the liquid into a perfectly level mold for it to set. Doing this in my garage was initially difficult because the ground is far from level. To address this, I started designing a work bench that would adjust its legs to completely level itself with a built in gyroscope. For the gyroscope, I used the MPU -6050 module which I connected directly to an Arduino Uno. I was able to collect the yaw, pitch and roll(YPR). The Arduino used trigonometric functions to find exactly how much longer each leg should get in order to return to level given the current YPR and set table dimensions. The legs move individually with a motor rotating a threaded rod as shown on the design section below.

Here is a section of my Arduino code:

mpu.dmpGetQuaternion(&q, fifoBuffer);
mpu.dmpGetGravity(&gravity, &q);
mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
double w = 3;
double l = 6;
double leg1 = 0;
double leg2 = 0;
double leg3 = 0;
double leg4 = 0;
double pitch = ypr[1] * 180/M_PI;
double roll = ypr[2] * 180/M_PI;
double x = (w*tan(pitch*0.01745329252)*12);
double y = (l*tan(roll* 0.01745329252)*12);

if(x>0){
leg1=leg1+x;
leg4=leg4+x;
}
else if (x<0){
leg2=leg2-x;
leg3=leg3-x;
}