Kenneth Yang
Published © GPL3+

Memsic2125 Accelerometer (Mx2125)

Need to gauge angles? Here's your module!

BeginnerProtip4 minutes6,658
Memsic2125 Accelerometer (Mx2125)

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×7
Mx2125 (Memsic2125)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Hookup

Fritzing of how to hook-up the Mx2125 to pins 2 (x-axis) and 3 (y-axis)

Mx2125 Size

Comparison to the Arduino Uno and a half size breadboard

Code

xyReader

Arduino
This is the one and only code file you will need to get the x and y axis angle
const int xP = 11;
const int yP = 12;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  pinMode(xP, INPUT);
  pinMode(yP, INPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
  int px, py;
  int ax, ay;

  px = pulseIn(xP, HIGH);
  py = pulseIn(yP, HIGH);

  ax = ((px / 10) - 500) * 8;
  ay = ((py / 10) - 500) * 8;

  Serial.print(ax);
  Serial.print("\t");
  Serial.print(ay);
  Serial.println();

  delay(100);

}

Credits

Kenneth Yang

Kenneth Yang

8 projects • 100 followers
Maker, developer, 3D content creator

Comments