#include <math.h>
void loop() {
int x_adc_value, y_adc_value, z_adc_value;
double x_g_value, y_g_value, z_g_value;
double roll, pitch, yaw;
x_adc_value = analogRead(x_out);
y_adc_value = analogRead(y_out);
z_adc_value = analogRead(z_out);
Serial.print("x = ");
Serial.print(x_adc_value);
Serial.print("\\t\\t");
Serial.print("y = ");
Serial.print(y_adc_value);
Serial.print("\\t\\t");
Serial.print("z = ");
Serial.print(z_adc_value);
Serial.print("\\t\\t");
x_g_value = ( ( ( (double)(x_adc_value * 3.3)/1024) - 1.65 ) / 0.330 );
y_g_value = ( ( ( (double)(y_adc_value * 3.3)/1024) - 1.65 ) / 0.330 );
z_g_value = ( ( ( (double)(z_adc_value * 3.3)/1024) - 1.80 ) / 0.330 );
roll = ( ( (atan2(y_g_value,z_g_value) * 180) / 3.14 ) + 180 );
pitch = ( ( (atan2(z_g_value,x_g_value) * 180) / 3.14 ) + 180 );
Serial.print("Roll = ");
Serial.print(roll);
Serial.print("\\t");
Serial.print("Pitch = ");
Serial.print(pitch);
Serial.print("\\n\\n");
delay(1000);
}