Accelerometers huh! No new term these days! Every practical phone these days has one! Accelerometers churn out data in two ways :
The one that i had is an analog one and is probably the first one that comes when you search with keywords Arduino Accelerometer on ebay/AliExpress. It(module) is based on Freescale ‘s MMA7361 analog 3Axis Accelerometer.
I bought it a while back and was curious to play with it. The pin description (thanks to the simplification done here) is as follows:
Without doing the RTFD(D-Datasheet) i quickly plugged in the board to read X values and to derive any conclusion and Alas! it failed.I then went thru the datasheet to find out the IC is initially in Sleep Mode and has to be awaken by pulling-Up the Sleep pin.
Just connect a 10k resistor to the Sleep Pin and to the 3.3V output pin and now we have most of the circuit set up.
Now just:
Simple as that!
Having deciphered it, i wrote a test code:
It worked as designed.
Then i thought that it will be better to try writing a library for it and learn how to write libraries in the process. The process turned out to be easy thanks to the documentation by Arduino.
My Library can be found here on github
Feel free to fork it and use it. Hoping the community finds it useful.
Cheers,
Rohit