title: distance measure using mpu 6050 accelerometer
body: <p>I want to calculate traveled distance of mpu 6050 sensor using the acceleration of x,y,z. How to get the traveled distance that sensor traveled using accelerometer values by integrating.Can you please explain the code example for getting the velocity and displacement</p>
  
  <pre><code>  a_present = aaReal.x * 9.8;
    a_average = (a_present + a_previous)  / 2;
  
    v_present = v_previous + a_average * 0.001 ;
  
    v_average = (v_previous + v_present) / 2;
  
  
  
    s_present = v_previous * 0.001 + 0.5 * a_average  * 0.001 * 0.001;
  
    Serial.println("v_present " + (String)v_present + "\t\ts_present  " +(String)s_present+"\t\ts_all "+(String)s_all + "\ta_real "+(String)a_present);
  
  
  
  
    a_previous = a_average;
    v_previous = v_present;
    s_all = s_all + s_present; 
  </code></pre>