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 pulseIn() function, it is possible to determine the rate of acceleration and to use that data for your purposes.
Step 1: What You Need?
1 x Arduino Board ( Arduino UNO R3 used in this tutorial.)
1 x Memsic 2125 Accelerometer
1 x Mini Breadboard or Breadboard
Male-to-Male Jumper Wires
1 x USB Type-B Cable ( Arduino UNO)
Optional
1 x Memsic 2125 Accelerometer
1 x Mini Breadboard or Breadboard
Male-to-Male Jumper Wires
1 x USB Type-B Cable ( Arduino UNO)
Optional
Don't have components? Don't worry. Just click the component's name.
Step 2: Build Your Circuit.
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 board. Connect digital pin 2 of the board 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.
Step 3: Upload The Code.
1. Select the Arduino board type: Select Tools >> Board >> Select your correct Arduino board used.
2. Find the port number by accessing device manager on Windows. See the section Port (COM&LPT) and look for an open port named "Arduino Uno (COMxx)". If you are using a different board, you will find a name accordingly. What matters is the xx in COMxx part. In my case, it's COM3. So my port number is 3.
Select the right port: Tools >> Port >> Select the port number.
3. You can find this code in the example of Arduino IDE.
Select File >> Examples >> 06.Sensors >> Memsic2125
Click press the "upload" button (see the button with right arrow mark).
Download:
Arduino IDESources:https://www.arduino.cc/en/Tutorial/Memsic2125
0 comments:
Post a Comment