Analog angle conversion from +70° to -70° I am using below sensor (accelerometer) .My application is a solar tracker, where I wanted to convert the sensor output into +70° to -70° format. 

My question is how can I convert the angle?

#define ADC_ref 2.56
#define zero_x 1.569
#define zero_y 1.569    
#define zero_z 1.569    
#define sensitivity_x 0.3    
#define sensitivity_y 0.3    
#define sensitivity_z 0.3

unsigned int value_x;
unsigned int value_y;
unsigned int value_z;

float xv;
float yv;
float zv;

float angle_x;
float angle_y;
float angle_z;

void setup() {    
  //analogReference(INTERNAL2V56);    
  Serial.begin(9600);    
}

void loop() {    
  value_x = analogRead(A0);

//  value_y = analogRead(A1);
  //value_z = analogRead(A2);

  Serial.print("voltage  of x");
  Serial.println(value_x);
  /*Serial.print("voltage  of y");
   Serial.println(value_y);
   Serial.print("voltage  of z");
   Serial.println(value_z);
   */
  //xv=(value_x/1024.0*2.5)/sensitivity_x;
/*  zv=(value_z/1024.0*ADC_ref-zero_z)/sensitivity_z;
  yv=(value_y/1024.0*ADC_ref-zero_y)/sensitivity_y;
  xv=(0.0032226562499999998*value_x)/sensitivity_x;
  angle_x =atan2(-yv,-zv)*57.2957795+90;

  Serial.print ("x= ");
  Serial.println (xv);
  Serial.print("x_degree= ");
  Serial.print(angle_x);
  Serial.println(" deg");    

  /*Serial.print(" g ");       

   Serial.print ("y= ");
   Serial.print (yv);
   Serial.print(" g ");



   Serial.print ("z= ");
   Serial.print (zv);
   Serial.print(" g ");

   Serial.print("\n");

   Serial.print("Rotation ");

   Serial.print("x= ");

   angle_x =atan2(-yv,-zv)*57.2957795+180;

   Serial.print(angle_x);
   Serial.print(" deg");
   Serial.print(" ");

   Serial.print("y= ");

   angle_y =atan2(-xv,-zv)*57.2957795+180;

   Serial.print(angle_y);
   Serial.print(" deg");
   Serial.print(" ");

   Serial.print("z= ");

   angle_z =atan2(-yv,-xv)*57.2957795+180;

   Serial.print(angle_z);
   Serial.print(" deg");
   Serial.print("\n");
   */
  delay(1000);
  //delay(1000);
}



Description
Datasheet of ADXL335


I have inclinometer off the shelf its Vout is 0~5&nbsp;V and angle measure from -70° to 70°, and I calculated as below.

void calcPos()
{    
  Sensor_Value=analogRead(A3); 
  voltage = Sensor_Value * ARDUINO_ANALOG_SCALING;
  tracker_actual_pos=(30*voltage)-75;
}
So atan2(y,x) gives the angle CCW from the x axis in radians, limited to [-pi,pi].  

If you want it converted to degrees CW from the Y axis, you would do 

azimuth=90.0-atan2(y,x)*57.295779;  


If you need to constrain it to -70,70 then:

azimuth_constrained=constrain(azimuth,-70,70);