interfacing arduino to Acclerometer MMA7361l

Hi

Am having trouble interfacing arduino to Acclerometer MMA7361l. Whenver am conncting MMA7361l to arduino its giving junk values. Here is how i connected it. X- Analog(3) Y-Analog(2) Z- Analog(1) Vss- 3v Arduino Gnd- GND

Here is the code am using:

int XPin = 3; // X 
int YPin = 2; // Y 
int ZPin = 1; // Z 
int valX = 0; 
int valY = 0; 
int valZ = 0; 
void setup() { 
Serial.begin(9600); 
} 
void loop() { 
valX = analogRead(XPin); 
valY = analogRead(YPin); 
valZ = analogRead(ZPin); 
Serial.print("X-"); 
Serial.print(valX); 
Serial.print(" Y-"); 
Serial.print(valY); 
Serial.print(" Z-"); 
Serial.print(valZ); 
Serial.print("\n"); 
delay(100); 
}

Can anybody tell me where am going wrong.is it correct to power the accelrometer from arduino 3v?

What about the other input pins on the accelerometer: g-select, sleep, and self-test? How are those pins connected?

Have you connected the X/Y/Z outputs to ANALOG pins A3-A5 or did you by chance connect them to digital pins D3-D5?

-- The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons

Whenver am conncting MMA7361l to arduino its giving junk values

"junk" has a specific meaning to you. Would you care to share your definition, or show us some results, and explain why you think they're junk?

@RuggedCircuits I used only 5 pins.3 for x,y,z and 2 for power supply. And rest pins are unconnected.

http://helderk.com/2009/06/arduino-acelerometro-mma7361/ he also used just 5 pins to interface the accelerometer.

@AWOL Sample Output 672 640 601 606 650 532 604 678 701

The values change even when i dont move the accelerometer.

Do you have 3.3nF on the outputs to minimize noise (as recommended by the datasheet)? Also a 0.1uF capacitor is recommended across the power pins of the accelerometer (as close to the accelerometer as possible).

The variations you’re seeing on the readings look like they could be explained by noise that might be fixed by the above changes.


The Quick Shield: breakout all 28 pins to quick-connect terminals

Here is how i connected it. X- Analog(3) Y-Analog(2) Z- Analog(1) Vss- 3v Arduino Gnd- GND

I'm hoping Vss to 3v3 is a typo. Vdd should go to 3v3 and Vss to GND.

I don't think it is just noise (although that will be a problem later on).

You should be seeing something like: [edit]

X    Y    Z
338  338  502

[/edit] The 650 or so counts is suspiciously close to 3.3 volts. Recheck your wiring. The more I look at the photo the less I'm convienced it is hooked up correctly. It's just a bit too out of focus to tell for sure. It looks like pins 1 to 6 should be on the near side of the breakout board.