Hi there,
I'am just trying to get the acceleration data's from my BMA020. I want to receive the data like in this table:
http://www.mikrocontroller.net/articles/BMA020#Speicheraufteilung
from 02h to 07h. But I have not too much experience with the arduino and the I²C bus.
Maybe someone can help me to handle this little project.
I think I have connected the wires correct, but my code is wrong.
Here it is:
#include <Wire.h>
byte data[6];
boolean ack = 0;
int BMA_x;void setup()
{
Wire.begin();
Serial.begin(9600);
Serial.println("- Läuft -");
delay (500);
}void loop ()
{Wire.beginTransmission (0x38);
Wire.send(0b0);
ack = Wire.receive();
Wire.send(0x02);
ack = Wire.receive();
Wire.endTransmission();Wire.requestFrom (0x38,6);
Wire.send(0x02);for (int i=0; i<6 ;i++){
data*=Wire.receive();*
}*
Serial.print("data_0:");*
Serial.println(data[0], BIN ); *
Serial.print("data_1:");*
Serial.println(data[1], BIN );*
Serial.print("data_2:");*
Serial.println(data[2], BIN);*
Serial.print("data_3:");*
Serial.println(data[3], BIN); *
Serial.print("data_4:");*
Serial.println(data[4], BIN);*
Serial.print("data_5:");*
Serial.println(data[5], BIN);*
Serial.println("");*
delay (1500);*
}[/quote]
I receive from the serial:
> - Läuft -
> data_0:10
> data_1:10010
> data_2:1000001
> data_3:101
> data_4:1000001
> data_5:11111000
>
> data_0:10
> data_1:10010
> data_2:10000001
> data_3:101
> data_4:1
> data_5:11111000
>
> data_0:10
> data_1:10010
> data_2:1000001
> data_3:101
> data_4:11000001
> data_5:11110111
>
> data_0:10
> data_1:10010
> data_2:11000001
> data_3:11
> data_4:1
> data_5:10000
data 2, 3, 4, 5, are looking good (they change when I move the sensor), but data at 0 and 1 don't change.
I think I can handle the calculating to decimal when I have got the right binary numbers.
Thank you for your help!