Hi, i'm trying to read data from a IMU (inertial movement unit
http://www.sparkfun.com/datasheets/Sensors/Accelerometer/ADXL345.pdf),
which commuicates with the I2C protocol to my arduino uno.
I'm using the following code:
#include <Wire.h>
byte a;
void setup()
{
Serial.begin(9600);
Wire.begin();
}
void loop()
{
// z-axis accelerometer
Wire.beginTransmission(0xA6); // the last bit of the address is write
Wire.send(0x36); //arduino seeks the correct register (z-axis value)
Wire.endTransmission();
Wire.requestFrom(0xA7,1); //arduino requests the value from the register of z-axis
//the last bit of the address is read
a=Wire.receive(); //the slave (IMU) sends the data
Serial.println("z-axis");
Serial.println(a,BIN);
}
I can't understand why the serial output of arduino is always 0. i made the correct links and i don't know if the mistake is about the serial.println part or about the I2C protocol part.
Could someone help me??