Recently i bought an arduino mega 2560 and an accelerometer MMA7361 and uploaded the following code..
#include <AcceleroMMA7361.h>
AcceleroMMA7361 accelero;
int x;
int y;
int z;
void setup()
{
Serial.begin(9600);
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
accelero.calibrate();
}
void loop()
{
x = accelero.getXRaw();
y = accelero.getYRaw();
z = accelero.getZRaw();
Serial.print("\nx: ");
Serial.print(x);
Serial.print("\ty: ");
Serial.print(y);
Serial.print("\tz: ");
Serial.print(z);
delay(500); //(make it readable)
}
but when i click on serial monitor, its always showing the same value.
x: 519 y: 519 z: 583
x: 519 y: 519 z: 583
x: 519 y: 519 z: 583
x: 519 y: 519 z: 583
x: 519 y: 519 z: 583
x: 519 y: 519 z: 583
x: 519 y: 519 z: 583
x: 519 y: 519 z: 583
x: 519 y: 519 z: 583
x: 519 y: 519 z: 583
x: 519 y: 519 z: 583
its not changing even if we move the accelerometer.. i connected 5v to vcc, then gnd and sleep pin to digital 1...
how can i rectify this problem??