MMA7361 SimpleAsHell

purchased my sensor from $6 free shipping!

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 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
  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)

 // 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(" ");
Serial.print(" ");
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");}


delay (500);

thank u . ? will try your code

Thank you too.

I just got some and that will save me a bit of time - I hope.


Um, sorry to butt in, but.......

I bought a similar one and it doesn't work.

I used this link to connect it

I am powering it with 3.3 volts.

This is the sketch

#include <AcceleroMMA7361.h>

AcceleroMMA7361 accelero;
int x;
int y;
int z;

void setup()
  accelero.begin(13, 12, 11, 10, A0, A1, A2);
  accelero.setARefVoltage(3.3);                   //sets the AREF voltage to 3.3V
  accelero.setSensitivity(LOW);                   //sets the sensitivity to +/-6G

void loop()
  x = accelero.getXAccel();
  y = accelero.getYAccel();
  z = accelero.getZAccel();
  Serial.print("\nx: ");
  Serial.print(" \ty: ");
  Serial.print(" \tz: ");
  delay(500);                                     //make it readable

This is all I get:

Calibrating MMA7361011..................................................
x: -2 	y: -2 	z: 100	G*10^-2
x: -2 	y: -2 	z: 100	G*10^-2
x: -2 	y: -2 	z: 100	G*10^-2
x: -2 	y: -2 	z: 100	G*10^-2
x: -2 	y: -2 	z: 100	G*10^-2
x: -2 	y: -2 	z: 100	G*10^-2
x: -2 	y: -2 	z: 100	G*10^-2
x: -2 	y: -2 	z: 100	G*10^-2
x: -2 	y: -2 	z: 100	G*10^-2
x: -2 	y: -2 	z: 100	G*10^-2
x: -2 	y: -2 	z: 100	G*10^-2
x: -2 	y: -2 	z: 100	G*10^-2

I shake the board around/about and NOTHING changes.


Buyincoins had it down for a couple of bucks, who pocketed the rest lol

Slight update:

I looked at the .cpp file and found this:

/// begin function to set pins: sleepPin = 13, selfTestPin = 12, zeroGPin = 11, gSelectPin = 10, xPin = A0, yPin = A1, zPin = A2.
/// When you use begin() with an empty parameter list, these standard values are used
void AcceleroMMA7361::begin()
begin(13, 12, 11, 10, A0, A1, A2);

So I connected it up as per.....

Still the same.

Though the names are a bit "vague".

I get the ST for SelfTest, SL for Sleep, 0G for ZeroG, but the other/last pin is designated GS - I think.
So I am guessing that is the GSelect pin.

Anyway, as I said: Same out put.