Problems with ADXL345 Accelerometer outputs
hello friends
i beginner in arduino. bought arduino uno , adxl345 3-axis accelerometer. copied code, gives me outputs shown in attached picture. know problem is? it's because of code or installation? should give me acceleration data in x, y , z directions, gives me question mark. thanx
below code used:
#include <wire.h>
#define device (0x53) // adxl345 device address when sdo pin (12) grounded
void setup()
{
wire.begin(); // join i2c bus (address optional master)
serial.begin(115200); // start serial output
// wake accelerometer
wire.begintransmission(device); // start talking adxl345 accelerometer on sen-10183 board: http://www.sparkfun.com/products/10183
wire.write(0x2d); // address on accel want set: power_ctl
wire.write(
; // value on address: measure(
wire.endtransmission();
}
void loop()
{
// ask accel send it's xyz values
wire.begintransmission(device); // start talking adxl345 accelerometer on sen-10183 board: http://www.sparkfun.com/products/10183
wire.write(0x32); // address on accel want read
wire.endtransmission();
// receive xyz values
wire.requestfrom(device, 6);
byte data[6];
(int i=0;i<6 && wire.available();i++) {
data = wire.read();
}
wire.endtransmission();
// parse them
int x = data[0] | (((int)data[1])<<
;
int y = data[2] | (((int)data[3])<<
;
int z = data[4] | (((int)data[5])<<
;
char buf[100];
sprintf(buf, "x:%d, y:%d, z:%d\r\n", x,y,z);
serial.print(buf);
delay(200);
}
thank u in advance
i beginner in arduino. bought arduino uno , adxl345 3-axis accelerometer. copied code, gives me outputs shown in attached picture. know problem is? it's because of code or installation? should give me acceleration data in x, y , z directions, gives me question mark. thanx
below code used:
#include <wire.h>
#define device (0x53) // adxl345 device address when sdo pin (12) grounded
void setup()
{
wire.begin(); // join i2c bus (address optional master)
serial.begin(115200); // start serial output
// wake accelerometer
wire.begintransmission(device); // start talking adxl345 accelerometer on sen-10183 board: http://www.sparkfun.com/products/10183
wire.write(0x2d); // address on accel want set: power_ctl
wire.write(


wire.endtransmission();
}
void loop()
{
// ask accel send it's xyz values
wire.begintransmission(device); // start talking adxl345 accelerometer on sen-10183 board: http://www.sparkfun.com/products/10183
wire.write(0x32); // address on accel want read
wire.endtransmission();
// receive xyz values
wire.requestfrom(device, 6);
byte data[6];
(int i=0;i<6 && wire.available();i++) {
data = wire.read();
}
wire.endtransmission();
// parse them
int x = data[0] | (((int)data[1])<<

int y = data[2] | (((int)data[3])<<

int z = data[4] | (((int)data[5])<<

char buf[100];
sprintf(buf, "x:%d, y:%d, z:%d\r\n", x,y,z);
serial.print(buf);
delay(200);
}
thank u in advance
Arduino Forum > Using Arduino > Installation & Troubleshooting > Problems with ADXL345 Accelerometer outputs
arduino
Comments
Post a Comment