Measure acceleration, tilt and rotation with the Memsic MX2125 Dual Axis Accelerometer.
More...
#include "simpletools.h"
Go to the source code of this file.
Macros |
#define | PI 3.141592653589793 |
| approximation of PI for conversting g to angular values like rotation and tilt.
|
Functions |
int | mx_accel (int axisPin) |
| Measure acceleration in terms of g (acceleration due to earth's gravity). A measurement of +/-1250 corresponds to approximately +/- 1 g.
|
int | mx_rotate (int xPin, int yPin) |
| Measure clockwise rotation assuming accelerometer is held vertical. Zero degree rotation is when the triangle on the MX2125 chip is pointing up.
|
int | mx_tilt (int axisPin) |
| Measure the level of tilt in terms of +/- 90 degrees. 0 degrees is when the top surface of the accelerometer chip is parallel to the ground.
|
Detailed Description
Measure acceleration, tilt and rotation with the Memsic MX2125 Dual Axis Accelerometer.
- Author
- Andy Lindsay
- Copyright
- Copyright (C) Parallax, Inc. 2012. All Rights MIT Licensed.
Function Documentation
int mx_accel |
( |
int |
axisPin | ) |
|
Measure acceleration in terms of g (acceleration due to earth's gravity). A measurement of +/-1250 corresponds to approximately +/- 1 g.
- Parameters
-
axisPin | Number of I/O pin connected to either MX2125's X or Y- axis pins. |
- Returns
- Value that represents 1250ths of a g acting on the axis. 1250ths is a nominal value, the accelerometer is not that precise.
int mx_rotate |
( |
int |
xPin, |
|
|
int |
yPin |
|
) |
| |
Measure clockwise rotation assuming accelerometer is held vertical. Zero degree rotation is when the triangle on the MX2125 chip is pointing up.
- Parameters
-
xPin | Number of I/O pin connected to either MX2125's x-axis pin. |
yPin | Number of I/O pin connected to either MX2125's y-axis pin. |
- Returns
- Integer degree value (0 to 359) that represents the clockwise angle of rotation.
int mx_tilt |
( |
int |
axisPin | ) |
|
Measure the level of tilt in terms of +/- 90 degrees. 0 degrees is when the top surface of the accelerometer chip is parallel to the ground.
- Parameters
-
axisPin | Number of I/O pin connected to either MX2125's X or Y- axis pins. |
- Returns
- Value from 0 to 90 that represents the tilt of that axis.