purchased my sensor from buyincoins.com $6 free shipping! http://www.buyincoins.com/details/mma7361-angle-sensor-inclination-accelerometer-acceleration-module-arduino-speed-product-10248.html
after searching high and low... i created and ripped off code to make it work very simple.... even included a pin map and notations!
// Thank you Babelduck Cybernetics!... WTF was everyone else doing? soo complicated!
// I searched high and low for damn code for this sensor... you saved me!
// I purchased this sensor from http://www.buyincoins.com for like $6 US free shipping!! I had the part in less than 12 days!
//Anyway, tested it with (Chinese knockoff) Arduino UNO ATmega328 and (Chinese knockoff) Arduino Mega ATmega1280.... (yes, I've purchased real arduino's in the past.. Back off of me! The ad claimed it was real... In order to return it, would have cost me $75 US)
/*
MMA7361 SimpleAsHell - for Arduino
Copyright (c) 2012 Richard Pesce. All right reserved.
This software is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this software; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-Richard Pesce (please give me a little credit)
PesceTech.com
*/
// Arduino Pins:
// x -> a0
// y -> a1
// x -> a2
// SL -> 3v3 (3.3v)
// 3v3 -> 3v3 (3.3v)
// gnd -> gnd
// just for my sanity, I'll say led is on the left and xyz is the front!!!
// the following is from my china made MMA7361 (I haven't used a level yet... these measurements were just from my celebrated eye LOL)
// x342 y351 z176 = flat on table chips down (upside down)
// x342 y351 z510 = opposite of above (right side up)
// x343 y191 z339 = x, y, z, sl, og side flat on table (nose is on table)
// x341 y524 z347 = 5v, 3v3, gnd, gs, st, side flat on table (ass is on table)
// x516 y360 z335 = LEFT (led) side flat on table (left side on table)
// x169 y355 z336 = opposite of above RIGHT (right side on table)
// when x > 342 it's going on it's left side
// when x < 342 it's going on it's right side
// when y > 354 it's going on it's ass
// when y < 354 it's going on it's nose
// when z < 339 it's going upside down
// when z > 339 it's going right-side up
void setup()
{
Serial.begin(9600); // Start the serial link so we can see the output in the Arduino IDE
}
void loop()
{
int x, y, z; // Variables to store the 3 readings
x = analogRead(A0); // Read the X axis reading
y = analogRead(A1); // Read the Y axis reading
z = analogRead(A2); // Read the Z axis reading
Serial.print("X:");
Serial.print(x);
Serial.print(" ");
Serial.print("Y:");
Serial.print(y);
Serial.print(" ");
Serial.print("Z:");
Serial.print(z);
Serial.println();
if (x > 342) {Serial.println("left");}
if (x < 342) {Serial.println("right");}
if (y > 354) {Serial.println("ass");}
if (y < 354) {Serial.println("nose");}
if (z > 339) {Serial.println("right side up");}
if (z < 339) {Serial.println("upside down");}
Serial.println("");
delay (500);
}