Arduino and the MMA7260QT 3-Axis Accelerometer

I recently bought me a MMA7260QT 3-Axis Accelerometer, and have not found much documentation on the device. I did find a quick start guide at, which is a great starting point, but thought something with a little more substance was in order.

So I hooked it all up, the 3.3v pin on the breakout board to the 3.3v on the Arduino and the GND to GND. Now because this is not a digital sensor but an analog sensor I hooked x to analog in 1, y to 2, and z to 3. I also connected GS1 to GND and GS2 went to 5V. This is the basic set up.


When I started coding using the LiquidWare tutorial I realized I needed a way to calibrate the unit, to basically have a resting point for the analog inputs, so I added  a momentary button to digital pin 7. When the button is pushed and held for approx. 3 seconds the Arduino reads all three analog inputs and creates a min reference and a max reference. While running the Loop() function and the proper calibration has been completed the arduino compares the high and low with the current analog in state, if it is out of range, the Arduino will send the current value to serial and is viewable with the serial monitor. Otherwise with the current code the Arduino will send “Stable” through the serial comm lines.

Feel free to use the code and have some fun with this cheap and easy to use accelerometer.

Here is the code compatible with Arduino 0018 IDE:

//Accelerometer testing

//Jeff Savaglio <>

// May 31, 2010

//Use of the Pololu acc01a Accelerometer using MMA1260QT 3-axis accelerometer

// set up the x,y,z axis

int x0;

int y0;

int z0;

// these are the x,y,z high points to be used for determing

// the max analog value while the device is at rest.

int xH;

int yH;

int zH;

// these are the x,y,z low points to be used for determing

// the min analog value while the device is at rest.

int xL;

int yL;

int zL;

//this is the calibration button hooked into digital pin 7

const int cal = 7;

int calState = 0;

void setup(){

Serial.begin(9600); // open the Serial port and run it at 9600 baud

pinMode(cal, INPUT); // set the pinMode of the calibration button to INPUT


void loop(){

if ( digitalRead(cal)==HIGH){

// read the x,y,z and add them to the calibration values

x0 = analogRead(1);

y0 = analogRead(2);

z0 = analogRead(3);

// set up the x,y,z highs

xH = x0 + 5;

yH = y0 + 5;

zH = z0 + 5;

// set up the x,y,z lows

xL = x0 – 5;

yL = y0 – 5;

zL = z0 – 5;


// now that we have calibrated the accelerometer we can read

// the inputs and see if there is a change.

x0 = analogRead(1);

y0 = analogRead(2);

z0 = analogRead(3);

if (x0 > xH || x0 < xL){ // if x0 is more or less then our set high

// and low print the value, you can add what

Serial.print(“x= “); // ever you want the program todo in the curly

Serial.print(x0); // brackets


}else if (y0 > yH || y0 < yL){ // this block is for the Y axis

Serial.print(“y= “);



}else if (z0 > zH || z0 < zL){ // and this is the Z axis.

Serial.print(“z= “);




Serial.print(” stable “); // if the accelerometer is at rest it will print

delay(1000); // a stable message.




~ by jsavaglio on June 1, 2010.

5 Responses to “Arduino and the MMA7260QT 3-Axis Accelerometer”

  1. Hello, Im confused it is assumed that the accelerometer has a maximum input voltage of 3.6 or 3.3V, I did know that adaptation as an Arduino driving voltage of 5V. If directly connected not supposed to burn the sensor??

    • I have it hooked into 5v only on the gs2 pin. It has not burnt out the sensor yet, try running it at 3.3v. I used five because I was getting weird feedback so I decided to try five volts there and it worked. Don’t folly my post to a T. Play with it and find your own results.

  2. Thank you so much for this post, really helped me out a lot for my project 😀

  3. Hello , i need to find how to wiring connections my board DC-SS009 with 7260 accelerometer to arduino , i gratefull for any help.

    • You Can wire it up the same as the one I posted in the post. Just use one side of the board. From what I’ve seen most of the host boards have the same pinouts (pins may be in different spots but they are the same).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: