A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/sparkfun/SparkFun_MMA8452Q_Particle_Library below:

GitHub - sparkfun/SparkFun_MMA8452Q_Particle_Library: SparkFun Triple Axis Accelerometer Breakout

SparkFun MMA8452Q 3-Axis Accelerometer Particle Library

A firmware library for the SparkFun's MMA8452Q 3-Axis Accelerometer.

The MMA8452Q is an I2C-based 3-axis accelerometer. It has user selectable full scales of ±2g/±4g/±8g with high pass filtered data as well as non filtered data available real-time. Unique features include programmable interrupts, tap-detection, and orientation detection.

Create an MMA8452Q 3-Axis Accelerometer Object & Initialize

To begin, create an MMA8452Q 3-Axis Accelerometer class object. This'll often go in the global section of the code:

//////////////////////////////
// MMA8452Q Object Creation //
//////////////////////////////
MMA8452Q accel; // This creates an MMA8452Q object, which we'll use to interact with the sensor

To initialize the sensor, call the begin([range], [odr]) function, where [range] is the full-scale range of the sensor and [odr] is the output data rate:

void setup()
{
	...
	accel.begin(SCALE_2G, ODR_1); // Set up accel with +/-2g range, and slowest (1Hz) ODR
	...
}

The full-scale range can be: SCALE_2G, SCALE_4G, or SCALE_8G (2, 4, or 8g).

The output-data rate (ODR) can be: ODR_800, ODR_400, ODR_200, ODR_100, ODR_50, ODR_12, ODR_6 or ODR_1 (800, 400, 200, 100, 50, 12, 6, or 1 Hz).

Update and Read Acceleration Values

All three of the accelerometer values are read in one fell swoop with the read() function:

Once read, the library updates six class variables: x, y, z -- the "raw" 12-bit values from the accelerometer -- and cx, cy, and cz, the calculated accelerations in g.

Serial.println("X: " + String(accel.x) + " | " + String(accel.cx, 2) + " g");
Serial.println("Y: " + String(accel.y) + " | " + String(accel.cy, 2) + " g");
Serial.println("Z: " + String(accel.z) + " | " + String(accel.cz, 2) + " g");

This product is open source!

Please review the LICENSE.md file for license information.

If you have any questions or concerns on licensing, please contact techsupport@sparkfun.com.

Distributed as-is; no warranty is given.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4