Go Down

Topic: Accelerometer MMA7361 readings (Read 889 times) previous topic - next topic

ghost_pattern

I have problems with the sparkfun MMA7361 readings, I only detect significant changes when for example, rotate the accelerometer along it's x axis (the y value changes indicating up/down), and so on, but when I move the accelerometer up and down and not along one axis, I don't detect anything, what's the problem with my readings... Thanks... PD, I connected all of the pins except ST (selftest) and the 0g and gselec....


Code: [Select]

#include <AcceleroMMA7361.h>

AcceleroMMA7361 accelero;

int x_change;
int y_change;

int x;
int y;
int z;
void setup()
{
Serial.begin(9600);
accelero.begin(13, 12, 11, 10, A4, A2, A0);
accelero.setARefVoltage(5);
accelero.calibrate();
}
void loop()
{
 x_change = x - accelero.getXAccel();
 y_change = y - accelero.getYAccel();
 x = accelero.getXAccel();
 y = accelero.getYAccel();
 
 if(x_change > 20)
 {
   Serial.print("LEFT\t");
 }
 else if (x_change < -20)
 {
   Serial.print("RIGHT\t");
 }
 else
 {
   Serial.print("NONE\t");
 }
 
 if(y_change > 15)
 {
   Serial.print("DOWN\n");
 }
 else if(y_change < -15)
 {
   Serial.print("UP\n");
 }
 else
 {
   Serial.print("NONE\n");
 }
 delay(500);
}

michinyon

You have to be quite observant to notice the output change when you move it.

Also,  if you move it at a steady speed upwards,  it's not accelerating,  it's moving at a steady speed.

You'd only see an acceleration at the beginning and end of that motion.

If you turn it over and over  and the apparent x,y,z vector of the result is pointing down,  then
it is probably working.

Go Up