Arduino and the MMA7260QT 3-Axis Accelerometer

•June 1, 2010 • 5 Comments

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.




The BeatBearing Build Pt. 2

•May 11, 2009 • Leave a Comment

Okay so I’ve continued on building, and I’ve been working on the wiring and multiplexer setup. Here are a couple of pictures, the first is the multiplexer and the second is the interface cable from the ribbon cables for the “switches” to the d-sub connectors for the multiplexers.

Well off to make my measurements for the acrylic, which I will be cutting and drilling by hand because I don’t have an open mechine shop close by. If your planning to go this route make sure you have the propper tools and go slow or you’ll find your self looking to buy more acrylic.

The beatbearing build

•May 7, 2009 • Leave a Comment

After learning the arduino microcontroller platform, Ive been looking for the prefect project to incorperate it into. With my love of music (enjoying, and creating), and technology, I’ve decided to work on building the beatbearing. (

I’m living in the Mississauga, Ontario Canada area and have been lucky enough to find all the required parts locally.

All the wire and electronics were purchased from sayal electronics on Mathison ave. Although I had to order the multiplex chips they came in only two days. I had ordered the arduino long ago from the robot shop based out of Montreal. What ever you do do not goto home depot for your acrilic, far to over priced, I was able to find some cheap at a local plastic wearhouse. The ball bearings I have are 11/16 as they are the closest I could find to 20mm, and I bought them from Canadian Bearing on Drew rd. I plan to purchase the washers, nuts & bolts from Bolts Plus on Torbram rd. Although I’m going to have to figure something out for the solder tabs.

Ubuntu 8.10 requiring a little touch to boot

•April 27, 2009 • Leave a Comment

I like many people out there have a problem while loading Ubuntu. I love my computer but I would also like to hit the power button, type my bios password, and come back in a couple of minutes to a login screen. Well I’ve always had a problem doing that with my laptop, it’s a Compaq Presario F700. So after molesting Google for an answer I’ve found it on the Ubuntu forums of all places.

Here is the link:

All that is needed is to open a terminal window  and use this command as root:

gedit  /boot/grub/menu.lst

and add acpi=noirq to the end of the line for the kernal that you boot ex:

kernel        /boot/vmlinuz-2.6.27-11-generic root=UUID=b075c631-2ecf-434c-8e46-5e6d2d761762 ro quiet splash acpi=noirq

reboot and have fun.

Compaq f700 And Ubuntu

•April 17, 2009 • Leave a Comment

So I’ve finaly decided to stick it out with Ubuntu instead of Kubuntu, And for good reasons too. The shear beauty of KDE alone couldn’t hold me down to the buggy Kubuntu, When I upgraded to the latest kernal, .14 I think, X server decided that there were no screens present and wanted nothing to do with my Nvidia video card. After multiple installs I reverted back to my beloved Ubuntu 8.10.

After the installation was complete I recommend hooking into a hard line and doing the updates and upgrades, as this will allow for the third party drivers to be installed. Once complete and rebooted, under the System>Administration>Hardware Drivers, we can install the video drivers. while your in there, disable the support for atheros 802.11 wireless lan cards.  Concidering the fact that I am running Ubuntu on a Compac, which features the lovely Atheros Ar5007 wifi card, well want to open a terminal and run this command:

sudo apt-get install linux-backports-modules-intrepid

After you get that all installed do a quick reboot and back to Hardware Drivers and enable the new ‘Support for 5xxx series of Atheros wireless lan cards. you may have to reboot again but you’ll get your wifi! enjoy.