Triple Axis Accelerometer MMA7361 Data sheet
This is a device that can measure angles and is used in tablets and mobile phones to detect the orientation. This particular circuit has a built in 3.3V regulator and so can be used with 5V equipment. It works by sending out three analogue values that correspond to the orientation of the device. All that is needed then is 3 ADC channels.
There are three other pins also on the device. OG which is a zero gravity detect, so if the device is dropped then this will trigger. ST is self test and should not be connected to anything and GS is the gravity select pin. When GS is ground the sensitivity is 1.5g and when +3.3 it is 6g ** Don't connect this pin to +5V **
All of the pins are marked on the underside of the board.
Using the breadboard connect the following pins:
X A0 (RB12)
Y A1 (RB1)
Z A2 (RB2)
|Click on link to see code. Use save link as to copy to local folder. To use with BV_COM, highlight link or use copy link location and then paste into the text transfer box|
The code is a very simple test to see if we can make the device work. Use test1() first and them move the board about, it is not that easy to see the values changing. A better function is xyz(). This establishes a base line at the start of the function and produces an output only when there is a significant change.
This is what to expect from both functions. The xyz() will only output if there is a change from the baseline. The device appears to measure an absolute value so it should be possible to measure when something is in the correct plane.