PLEASE HELP! - Arduino Mega + MMA7260Q Accelero...

Hi Guys,

I've searched the forums but have found no answer.

I have an Arduino Mega, and 5 MMA7260Q Accelerometers. For the moment, I'm just trying to get 1 accelerometer working, but this is turning out to be very hard.

I have plugged the VCC into 3v3, the ground into GND, X Y Z inputs into analog 0 1 2 respectively and GS1 GS2 SLP into digital 22 23 24 respectively.

Specs can be read here: * http://www.sparkfun.com/datasheets/Accelerometers/MMA7260Q-Rev1.pdf

At the moment this is my code:

const int pinx =0 ; const int piny =1 ; const int pinz =2 ; const int GS1 = 22; const int GS2 = 23; const int SLP = 24; int valx =0; int valy=0; int valz=0;

void setup() { Serial.begin(9600); pinMode(GS1, OUTPUT); pinMode(GS2, OUTPUT); pinMode(SLP, OUTPUT); }

void loop() { digitalWrite(GS1, LOW); digitalWrite(GS2, LOW); digitalWrite(SLP, HIGH); valx = analogRead(pinx); valy = analogRead(piny); valz = analogRead(pinz);

Serial.print(valx); Serial.print(" "); Serial.print(valy); Serial.print(" "); Serial.println(valz);

delay(5); }

Also, I forgot to add that Im only getting truly 'random' noise from the analogue input ports atm. :( cries

Thanks really apreciated, Lee.

Also, I forgot to add that Im only getting truly 'random' noise from the analogue input ports atm

Really? Do you see any significant differences between x, y and z axes? Could you show some of your results?

(please use the "#" (Code) button when posting code).

Ah sorry about that and cheers for this quick response. OK, these results are from me moving the accelerometer left then back to normal, but it just seems totally random, there is no correlation (i.e. when I go back to starting position).

180 180 180 180 181 181 181 181 180 180 182 180 181 181 181 182 182 181 180 181 181 181 179 180 183 181 180 181 180 182 180 184 181 182 185 180 182 181 181 181 180 181 180 180 180 180 181 180 181 181 179 181 181 181 182 181 181 181 181 181 181 181 181 180 182 180 180 182 180 180 181 180 181 180 180 181 181 181 181 182 181 181 180 184 180 178 181 180 181 180 184 181 181 180 180 181 181 180 180 180 181 181 181 185 182 182 181 181 184 181 181 180 181 179 180 181 180 181 181 180 181 181 181 181 181 182 181 181 183 180 181 181 176 181 179 180 177 180 180 176 181 181 180 180 181 181 181 182 180 183 180 183 180 180 181 180 181 181 180 181 180 181 181 181 181 181 181 181 180 182 181 181 181 180 180 180 180 181 181 180 181 180 180 181 181 180 182 181 175 181 180 181 181 181 183 181 180 180 181 183 180 181 181 180 181 181 179 181 182 180

and when I put my hand near/on the analogue inputs:

735 670 734 735 671 734 735 671 735 736 672 734 737 671 731 735 672 735 737 671 734 734 670 736 735 671 733 736 672 734 736 674 735 736 785 738 736 783 735 734 698 733 734 675 736 733 696 737 735 727 751 735 755 762 735 778 767 736 754 763 734 688 750 734 672 748 734 682 751 734 710 755 736 753 765 740 777 773 736 761 768 736 706 752 730 675 744 735 686 746 735 712 753 736 741 759 738 772 768 738 776 771 736 727 757 736 677 745 737 675 745 736 688 750

see its just noise :(

OK, the hand noise is not good. Check your grounds.

With the accelerometer still and horizontal, the x and y outputs should be half the supply voltage, and the z axes should be half the supply, +/- (depending on orientation) 800mV.

This should be easy to check with a multimeter.

OK thanks, no I'll try that soon.

However I think I just got it working, had SLP in 23, not 24 (whoops!). Now when I move it fast I seem to get 0 or lower values (possibly because it's on the low g setting and it doesn't pick the change in acceleration up) and when I put my hand/on near the analogue inputs I get no change in readings.

Also, when I tilt the accelerometer on it's side, y changes, and then changes back when I tilt it back.

All the values seem to bouncing around 250x, 330y, 200z, so I think woo its working :D

Cheers, Lee.