Memsic 2125 Accelerometer using Arduino

Arduino Memsic 2125 Accelerometer

The Memsic 2125 (datasheet) is a two-axis accelerometer capable of measuring acceleration up to plus or minus 2g. It has a simple digital interface: two pins (one for each axis) emit pulses whose duration corresponds to the acceleration of that axis. By measuring the length of that pulse, in microseconds, using the Arduino’s pulseIn() function, it is possible to determine the rate of acceleration and to use that data for your purposes.

Circuit

Arduino Memsic 2125 Accelerometer

Use the small triangle on the Memsic to properly orient the sensor on your breadboard. Connect the 5V and GND pins of the Memsic 2125 to the power and ground ports on the Arduino. Connect digital pin 2 of the Arduino to the X out pin of the accelerometer, and digital pin 3 to the Y out pin.

Your Arduino must be connected to your computer in order for it to transmit serial data.

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Schematic:

Memsic 2125 Accelerometer schematic

Code

/*
Memsic2125

Read the Memsic 2125 two-axis accelerometer.  Converts the
pulses output by the 2125 into milli-g's (1/1000 of earth's
gravity) and prints them over the serial connection to the
computer.

The circuit:
* X output of accelerometer to digital pin 2
* Y output of accelerometer to digital pin 3
* +V of accelerometer to +5V
* GND of accelerometer to ground

http://www.arduino.cc/en/Tutorial/Memsic2125

created 6 Nov 2008
by David A. Mellis
modified 30 Aug 2011
by Tom Igoe

This example code is in the public domain.

*/
// these constants won't change:
const int xPin = 2;     // X output of the accelerometer
const int yPin = 3;     // Y output of the accelerometer

void setup() {
  // initialize serial communications:
  Serial.begin(9600);
  // initialize the pins connected to the accelerometer
  // as inputs:
  pinMode(xPin, INPUT);
  pinMode(yPin, INPUT);
}

Read more: Memsic 2125 Accelerometer using Arduino

Leave a Comment

Your email address will not be published. Required fields are marked *