22 float angle = atan2(fy, fx) * 180.0 /
PI;
24 int rotation = (int) angle;
26 if (rotation < 0) rotation = 360 + rotation;
28 return (
int) rotation;
35 if(fa > 1250.0) fa = 1250.0;
36 if(fa < -1250.0) fa = -1250.0;
37 float angle = asin(fa/1250.0) * 180.0 /
PI;
38 int tilt = (int) angle;
int mx_rotate(int xPin, int yPin)
Measure clockwise rotation assuming accelerometer is held vertical. Zero degree rotation is when the ...
Measure acceleration, tilt, and rotation with the Memsic MX2125 Dual-axis Accelerometer.
int mx_accel(int axisPin)
Measure acceleration in terms of g (acceleration due to earth's gravity). A measurement of +/-1250 co...
#define PI
Approximation of PI for converting g to angular values like rotation and tilt.
int mx_tilt(int axisPin)
Measure the level of tilt in terms of +/- 90 degrees. 0 degrees is when the top surface of the accele...