MMA7361 - Arduino Due

Estoy intentando obtener los valores de mi acelerometro MMA7361 conectado a una placa de Arduino Due usando el siguiente codigo:

const unsigned X_AXIS_PIN = 0; const unsigned Y_AXIS_PIN = 2; const unsigned Z_AXIS_PIN = 4; void setup() { ** Serial.begin(9600);** } void loop() { ** Serial.print(analogRead(X_AXIS_PIN));** ** Serial.print(" ");** ** Serial.print(analogRead(Y_AXIS_PIN));** ** Serial.print(" ");** ** Serial.println(analogRead(Z_AXIS_PIN));** ** delay(100);** }

y nada pasa, ¿alguna sugerencia?

Are those analog input pins ?

Did you check whether this is a 5V or 3V device ?

You also have to “set it up” before reading the values.

The way I have mine is that it sends the values as “data”.

So you don’t get analogue voltages, you get the values sent to your code.

Maybe check the examples.

Try this one:

#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(5);                   //sets the AREF voltage to 3.3V
  accelero.setSensitivity(LOW);                   //sets the sensitivity to +/-6G
  accelero.setOffSets(18,11,100);
  accelero.calibrate();
}

void loop()
{
  x = accelero.getXAccel();
  y = accelero.getYAccel();
  z = accelero.getZAccel();
  Serial.print("\nx: ");
  Serial.print(x);
  Serial.print(" \ty: ");
  Serial.print(y);
  Serial.print(" \tz: ");
  Serial.print(z);
  Serial.print("\tG*10^-2");
  delay(500);                                     //make it readable
}